Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set fetch mode - always set to PDO::FETCH_ASSOC #123

Open
Mariyo opened this issue Nov 14, 2016 · 1 comment
Open

Cannot set fetch mode - always set to PDO::FETCH_ASSOC #123

Mariyo opened this issue Nov 14, 2016 · 1 comment

Comments

@Mariyo
Copy link

Mariyo commented Nov 14, 2016

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
}
@fvgoto
Copy link

fvgoto commented Sep 28, 2023

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants