Write queries as `db`.`table` as opposed to `table`
Posted by: JDelage (---.hsd1.wa.comcast.net)
Date: June 10, 2011 01:03AM

Hi,

I'm writing a user registration function in PHP PDO, and I have found that my query will only run fine if it is written like this:

<?php
$dbHost="localhost";
$dbName="project";
$dbUser="admin";
$dbPassword="abcd";
$dbh=new PDO("mysql:host=$dbHost;dbame=$dbName", $dbUser, $dbPassword);
$query=$dbh->prepare("INSERT INTO project.users (userName, userEmail) VALUES (?,?)"winking smiley;
.....

On the other hand, it will not run if I write:
...
$query=$dbh->prepare("INSERT INTO users (userName, userEmail) VALUES (?,?)"winking smiley;
...

Why is it that I need to precise "project.users"? Why isn't it enough to enter the table name, given that the db name itself is already in the PDO object?

Thank you!

JDelage

Options: ReplyQuote
Re: Write queries as `db`.`table` as opposed to `table`
Posted by: stevenmartin99 (---.b-ras1.srl.dublin.eircom.net)
Date: June 10, 2011 01:08AM

why are you asking this on the wamp forum?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote
Re: Write queries as `db`.`table` as opposed to `table`
Posted by: JDelage (---.hsd1.wa.comcast.net)
Date: June 10, 2011 01:25AM

Maybe it's the wrong place for it. I'll go somewhere else, sorry.

Options: ReplyQuote
Re: Write queries as `db`.`table` as opposed to `table`
Posted by: stevenmartin99 (---.b-ras1.srl.dublin.eircom.net)
Date: June 10, 2011 01:37AM

its just you should ask it at the PDO extention site?

Steven Martin
stevenmartin99@gmail.com
stevenmartin99@hotmail.com
PampServer.com - [pampserver.com]

Options: ReplyQuote


Sorry, only registered users may post in this forum.