本文整理汇总了PHP中Cake\ORM\Table::deleteAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Table::deleteAll方法的具体用法?PHP Table::deleteAll怎么用?PHP Table::deleteAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\ORM\Table
的用法示例。
在下文中一共展示了Table::deleteAll方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeDelete
/**
* Also deletes the nodes in the subtree of the entity to be delete
*
* @param \Cake\Event\Event the beforeDelete event that was fired
* @param \Cake\ORM\Entity the entity that is going to be saved
* @return void
*/
public function beforeDelete(Event $event, Entity $entity)
{
$config = $this->config();
$this->_ensureFields($entity);
$left = $entity->get($config['left']);
$right = $entity->get($config['right']);
$diff = $right - $left + 1;
if ($diff > 2) {
$this->_table->deleteAll(["{$config['left']} >=" => $left + 1, "{$config['left']} <=" => $right - 1]);
}
$this->_sync($diff, '-', "> {$right}");
}
示例2: testDeleteAllAliasedConditions
/**
* Test deleting many records with conditions using the alias
*
* @return void
*/
public function testDeleteAllAliasedConditions()
{
$table = new Table(['table' => 'users', 'alias' => 'Managers', 'connection' => $this->connection]);
$result = $table->deleteAll(['Managers.id <' => 4]);
$this->assertSame(3, $result);
$result = $table->find('all')->toArray();
$this->assertCount(1, $result, 'Only one record should remain');
$this->assertEquals(4, $result[0]['id']);
}
示例3: gc
/**
* Helper function called on gc for database sessions.
*
* @param string $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed.
* @return bool True on success, false on failure.
*/
public function gc($maxlifetime)
{
$this->_table->deleteAll(['expires <' => time()]);
return true;
}
示例4: cleanDrafts
/**
* Delete all draft entries in database
*
* @param \Cake\ORM\Table $table Table instance
*
* @return bool
*/
public function cleanDrafts(Table $table)
{
return $table->deleteAll(['online' => -1]);
}
示例5: gc
/**
* Helper function called on gc for database sessions.
*
* @param string $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed.
* @return bool True on success, false on failure.
*/
public function gc($maxlifetime)
{
return $this->_table->deleteAll(['expires <' => time() - $maxlifetime]);
}