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

how to know sql query #121

Open
arkgnan opened this issue Aug 19, 2016 · 6 comments
Open

how to know sql query #121

arkgnan opened this issue Aug 19, 2016 · 6 comments

Comments

@arkgnan
Copy link

arkgnan commented Aug 19, 2016

in notorm documentation we know to get sql query use (string) $table but i didn't get any result when use it.
$data = array('name'=>'testing','age'=>'25') $result = $db->tablename->insert($data); echo (string) $result ;
i know the query is insert into tablename (name,age) values('testing','25'); i want to catch the query to variable. but echo (string) $result didn't show anything.

@surferxo3
Copy link

The correct syntax is var_dump($db->tablename()->insert($data));

@arkgnan
Copy link
Author

arkgnan commented Aug 23, 2016

var_dump only show boolean values (true or false)

@tablecell
Copy link

$db->debug = true;

@surferxo3
Copy link

surferxo3 commented Dec 28, 2016

Setting $db->debug = true does nothing. How to use the callback with debug as suggested in their documentation? I tried all possible ways with no luck.

Does anyone have a working example of this debug callback functionality? If yes please do share the code snippet.

Thanks

@tablecell
Copy link

tablecell commented Dec 28, 2016

@```
include "./notorm-master/NotORM.php";
$pdo = new PDO("mysql:dbname=test",'username','password');
$db = new NotORM($pdo);
$db->debug=function($query, $parameters){
echo "query: ".$query.' with param: '.var_export($parameters,1);
};

// or $db->debug=true;
$app = $db->users()->select('now()')->limit(1);
foreach ($app as $value){
print_r($value->jsonSerialize());
}

exit;

@surferxo3
Copy link

Fully working notom example code with debug functionality can be found here: https://gist.github.com/surferxo3/2a1c06b9b5b373e6f1dbb2f0e1bd9250

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

3 participants