本文整理匯總了PHP中DBModel::batchSave方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBModel::batchSave方法的具體用法?PHP DBModel::batchSave怎麽用?PHP DBModel::batchSave使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DBModel
的用法示例。
在下文中一共展示了DBModel::batchSave方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testBatchSave
public function testBatchSave()
{
$foo = new Foo;
$foo->ID = 'SomeFoo';
// No foofoo -> invalid
$bar = new Bar;
$bar->ID = 'Somebar';
$bar->barbar = '...';
$bar->foo = $foo;
try
{
DBModel::batchSave(array($foo, $bar));
$this->fail('Expected exception');
}
catch (ValidationException $e)
{
$bar2 = Bar::get('Somebar');
$foo2 = Foo::get('SomeFoo');
$this->assertNull($bar2);
$this->assertNull($foo2);
$this->assertEquals('FooFoo is required', $foo->foofoo_error);
}
}
示例2: testBatchSave
public function testBatchSave()
{
$nathan = new MockModel('nathan', null, 'email@email.com');
$nathan->shadowProperty = 'Some Value';
$nathan->someRandomValue = 2;
$nele = new MockModel('nele', null, 'email2@email.com');
$nele->shadowProperty = 'Some Value';
try
{
DBModel::batchSave(array($nathan, $nele));
$this->fail('Exception expected');
}
catch (ValidationException $e)
{
$this->assertEquals('Integer is required', $nele->someRandomValue_error);
$this->assertNull(MockModel::getByName('nathan'));
}
$nele->someRandomValue = 3;
DBModel::batchSave(array($nathan, $nele));
$this->assertNotNull(MockModel::getByName('nathan'));
$this->assertNotNull(MockModel::getByName('nele'));
}