krak3n
(Chris)
March 30, 2009, 11:08am
1
Hi
I'm trying to uses updateAll to change some records parent (foreign key). But the update doesn't update any records:
ImgdbImg::model() -> updateAll(array('parent' => $this -> parent), 'parent = :parent', array(':parent' => $this -> id));
To me, this should work fine, basically this is just updating records where a parent = x to a new parent number which links to another table but the records do not get updated, I've checked the the keys and all its correct.
is confuddled
qiang
(Qiang Xue)
March 30, 2009, 11:24am
2
Did you check the generated SQL? Is that what you want to do?
krak3n
(Chris)
March 30, 2009, 11:33am
3
How do I ge the generated SQL code?
qiang
(Qiang Xue)
March 30, 2009, 11:45am
4
Turn on logging (check the guide) without setting any level and category log filters in a log route.
krak3n
(Chris)
March 30, 2009, 12:41pm
5
It seems that if in your condition you have a bind that has the same name as an attribute to be updated, the update fails, changing the above code to:
<?php
ImgdbImg::model() -> updateAll(array('parent' => $this -> parent), 'parent = :id', array(':id' => $this -> id));
This code completed the update as expected where as the code in my first post does not.
Chris