notorm
notorm copied to clipboard
Cannot set fetch mode - always set to PDO::FETCH_ASSOC
Hi, this is not a bug, but maybe feature request. It would be cool, if I would able to decide, which fetching mode will be used in results. I would like to get result as instances of object:
foreach ($db->application()->fethmode(PDO::FETCH_CLASS, 'MyApplicationClass') as $application) {
// get all applications as instances of class: "MyApplicationClass"
echo "$application->title\n"; // print application title
}
Very old issue, but for those still looking for it:
The PDO connection used to instantiate NotORM can be set up to return objects: https://www.php.net/manual/en/pdo.setattribute.php#101800
So based on the setup snippet from notorm.com:
include "NotORM.php";
$pdo = new PDO("mysql:dbname=software");
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
$db = new NotORM($pdo);