[SOLVED] Â sql query error |
3/13/2019 6:24:22 PM |
PHPRunner General questions | |
C
CTom author
Hi, |
|
C
|
CTom author 3/14/2019 |
Hi, I am trying to use a query which updates a field in the latest added record in a table. I have added this in the After record added events(Add page). $sql = "SELECT @last_id := MAX(mid) FROM malp; UPDATE malp SET poli = CONCAT('Start:', mxds , ' ', mxde , ' ', emit ) WHERE mid=@last_id;";CustomQuery($sql); While the query works fine in phpmyadmin and the dbmanager I'm using, in phprunner it throws errors. The update works fine but I don't want to update all rows when adding a new record. I guess that there is a particular syntax here(or I'm particularly dumb) but anyway, any help is greatly appreciated. <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=87340&image=1&table=forumreplies' class='bbc_emoticon' alt=':blink:' /> Thanks. C
|
admin 3/15/2019 | |
If you check AfterAdd documentation event you will see that you already have access to new ID, no need to perform an extra SQL Query: |
C
|
CTom author 3/17/2019 |
If you check AfterAdd documentation event you will see that you already have access to new ID, no need to perform an extra SQL Query: https://xlinesoft.com/phprunner/docs/after_record_added.htm Assuming that "mid" is your key column you can access its value as $keys["mid"]
|