I needed to do some table locking. Just call the method from the controller to lock and unlock your tables. The code below is only tested with MySQL and InnoDb tables. Put it in app_model.php
{code }
<?php
class AppModel extends Model {
function lockTableRW() {
$this->lockTable('READ');
$this->lockTable('WRITE');
}
function lockTable($type='READ') {
$dbo = $this->getDataSource();
$dbo->execute('LOCK TABLES '.$this->table.' '.$type);
}
function unlockTables() {
$dbo = $this->getDataSource();
$dbo->execute('UNLOCK TABLES');
}
}
Lämna ett svar