I am trying to find the best way to do this, better if I could use Zend_db_table. Basically I am inserting a row and one of the values comes from the same DB, this value changes constantly so I need to be sure the data inserted is valid. I can't query first for the value and then append it to the insert query because between the two queries the data could change and I end up inserting the wrong value. I wonder if LOCKING the table is the way to go or if Zend has a shortcut.
I'm using Mysql.
[EDITED]
For example: This table has a field called item_number, and for each new row I take the last item_number+1 (from the same item_family) and insert with it. It is a manual increment.
TABLE ITEMS
| item_id | item_family | item_number | name |
| 15 | 1 | 10 | Pan |
| 16 | 2 | 1 | Dress |
| 17 | 1 | 11 | Spoon |
In this example you see that the next row from item_family 1 has its item_number = 11 because the previous row from the same item_family was 10.
Thanks!