Page 1 of 1

PDO Delete Statement Fails

Posted: Mon Aug 27, 2007 5:01 pm
by SwizzCodes
feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Hi there,

so I'm trying to remove some rows over 3 tables with this statement:

[syntax="sql"]DELETE 
	contents, 
	contentVersions, 
	images 
FROM 
	contents, 
	contentVersions, 
	images
WHERE
	contents.cid = 2 AND 
	contentVersions.cid = contents.cid AND 
	images.vid = contentVersions.vid
Works perfectly if executed through my QueryBrowser, but fails with PDO.
Anyone know why?

[s]thanks[/s] thanks!
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.

Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.

feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]

Posted: Mon Aug 27, 2007 5:23 pm
by volka
"fails" mean "There is an error message which I forgot to post"? ;)

Posted: Mon Aug 27, 2007 5:34 pm
by SwizzCodes
oops:
Fatal error: Call to a member function execute() on a non-object in /Users/immanuelhaussermann/Sites/Netapplications/CMS/library/content/ContentManager.php on line 122
So the statement doesn't seem to be valid.

So I escape the execute command and it tells me:
[2] => Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.
I don't get that one. I've used fetch() on the previous statement, so it shouldn't be buffered anymore, right?

Posted: Tue Aug 28, 2007 4:14 am
by volka
fetch() only fetches one record from the result set. Is it possible that there are still other unfetched records in the result?
Also take a look at http://de2.php.net/PDOStatement-closeCursor

Posted: Tue Aug 28, 2007 12:23 pm
by SwizzCodes
there is only 1 row to fetch.. and it's also limited to 1 in the query, but I've got around it by using fetchAll(). Not as nice as fetch(), but working.

thank you anyway :)