PHP: "->" not working on mysql resultset -
i have strange behaviour. untilo today using -> retrieve member variables mysql resultset, such
$username = $result->user_name
but not working in current project.
$sth = self::$dbconnection->prepare("select user_id, user_name users"); $sth->execute(); $result = $sth->fetch(); $test = $result->user_password_hash; // $test null $test = $result["user_password_hash"]; // works
????
after fixing parse error, if want object:
$result = $sth->fetch(pdo::fetch_obj);
or:
$result = $sth->fetchobject();
or set mode before using fetch()
:
$sth->setfetchmode(pdo::fetch_obj);
Comments
Post a Comment