MDB2 Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aliasxneo
Forum Contributor
Posts: 136
Joined: Thu Aug 31, 2006 12:01 am

MDB2 Help

Post by aliasxneo »

I couldn't get any help on the PEAR forums (as expected) so that's why I'm hoping someone here can help.

I'm trying to use prepared statements but I have no idea what's going wrong. Here is the code that fails:

Code: Select all

$test = $this->mysql->prepare($this->sql['sel_char_name'][0], $this->sql['sel_char_name'][1], MDB2_PREPARE_RESULT);
And the code that sets the $this->sql array:

Code: Select all

$sql['sel_char_name'] = array("SELECT * FROM `characters` WHERE `name` = ?", array("text"));
The code is returning a PEAR Error and when I get the debug info this is what I get:

Code: Select all

MESSAGE: _doQuery: [Error message: Could not execute statement]
[Last executed query: PREPARE MDB2_STATEMENT_mysql_fb77ee68d9e6360a6039a25d02b31489 FROM Object id #42]
[Native code: 1064]
[Native message: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Object id #42' at line 1]
I have no idea what is happening. What is Object id #42? As far as I know I never even gave any objects, just a string and an array as should be given. Does anyone have any idea what I might be doing wrong? Any help is greatly appreciated (As I am totally lost). Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

What does the prepare call return?
aliasxneo
Forum Contributor
Posts: 136
Joined: Thu Aug 31, 2006 12:01 am

Post by aliasxneo »

feyd wrote:What does the prepare call return?
In my case it returns a MDB2_Error. That's why I called debug info. My code literally looks like:

Code: Select all

$test = $this->mysql->prepare($this->sql['sel_char_name'][0], $this->sql['sel_char_name'][1], MDB2_PREPARE_RESULT);
echo $test->getDebugInfo();
And I get the message I put in my first post.

Also, I have been looking for a function that gives the last query sent in MDB2 but I can't seem to find anything. If anyone knows or can find it, it would be very useful as to describing what is going wrong.
Post Reply