Forums | Mahara Community

Developers /
update_record can't have same column in both SET and WHERE?


anonymous profile picture
Account deleted
Posts: 117

04 September 2009, 22:06

Is there any particular reason why update_record function won't allow the same column name to appear in the SET and WHERE? 

 I'm redoing the photo section to allow galleries that other users can see and in the page to delete an album, I'm allowing users to choose to move the photos in the album or just delete them. To move them, tried the following:

update_record('artefact_file_image', (object) array('album' => $values['move']), array('album' => $values['id']));

Where 'move' is the id of the photo album that the photos will be moved to and 'id' is the id of the album being deleted. 

However, since the column "album" appears both in the columns being updated and in the where, the update_record function removes the album column from the columns being updated.  What's up with that?

anonymous profile picture
Account deleted
Posts: 117

04 September 2009, 22:37

Ah. Nevermind. I didn't realize there was an execute_sql function for situations like this.  All fixed.
anonymous profile picture
Account deleted
Posts: 1643

09 September 2009, 19:26

DML is a nasty library we borrowed from elsewhere.. it has strange behaviour just like this. The upgrade path uses execute_sql a lot for this reason Wink

anonymous profile picture
Account deleted
Posts: 117

10 September 2009, 1:57

Odd, but overall, it's still a pretty useful library.
4 results