return anonymous user if no user is logged in to the context.
when getOne("Profile") is performed on anonymous user, will return null, so some error might be thrown.
modx->db->dbfunctions is now deprecated, so use the actual function from $modx itself.
for more information, refer here:
http://rtfm.modx.com/display/revolution20/Upgrading+MODx#UpgradingMODx-VersionSpecificChanges
http://rtfm.modx.com/display/revolution20/Summary+of+Legacy+Code+Removed+in+2.1
Example of a big change:
$modx->db->query is completely different from $modx->query
So you may use parseBinding to do your query.
Example:
$sSelectSQL = "select `parent`, `context_key` , id, `alias`, pagetitle, longtitle from modx_site_content where context_key=:contextand parent=:parent and `alias`=:alias and (published=0 or deleted=1)";
$aParam = array(":context" => "web",
":parent" => 1, ":alias" => "somealias");
$sResultSelectSQL = $modx->parseBindings($sSelectSQL, $aParam);
$stmt = $modx->query($sResultSelectSQL);
if (! $stmt) throw new Exception("SQL Failed: " . $sResultSQL);
//to fetch all
$aCount = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($aCount as $oRow) {
echo $oRow["id"];
}
//to fetch one
$oRow = $stmt->fetch($PDO::FETCH_ASSOC);
echo $oRow["id"];
And other class based method:
//to get an object row
$oRes = $modx->getObject("modResource", array("context_key" => "web", "parent" => 1, "alias" => "somealias"));
echo $oRes->get("id");
No comments:
Post a Comment