I'd recommend opening a transaction before the first read, and then
commit after the save(). It's not usually a good idea to lock anything
in a database if you don't have to. But with transaction isolation, you
should be able to get repeatable read consistency.
However, if you use a non-transactional storage technology such as
MySQL's MyISAM tables, it may be the only option to use table locking to
achieve read consistency. Zend_Db has no explicit feature for this, so
you may have to do it by accessing the internal connection object:
$db->getConnection()->exec('LOCK TABLES mytable READ');
...do your work against mytable...
> -----Original Message-----
> From: Florian Hoenig [mailto:[hidden email]]
> Sent: Tuesday, April 03, 2007 1:47 AM
> To: [hidden email] > Subject: [fw-db] Read locks
> I haven't been using Zend_Db_Table down to it's full feature set yet,
> it's still changing a lot, so this might be a newbie question:
> I have concurrent access to a table and one thread takes out a row-set
> iterates over it, doing some time-consuming operations and then
> writes a row with ->save().
> The other thread is doing the exact same thing just cascaded in time.
> What's the best-practice here for read-locking this selected rowset so
> read-after-read conflict occurs ?
> Many thanks,