本文整理汇总了PHP中Test::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Test::findAll方法的具体用法?PHP Test::findAll怎么用?PHP Test::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Test
的用法示例。
在下文中一共展示了Test::findAll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRowMethods
function testRowMethods()
{
$id = $this->addRow();
$tr = new Test();
$loaded = $tr->load($id);
$this->assert($updatedRow = $loaded, "Test->load() failed: " . var_export($loaded, 1));
$exp = $tr->export();
$this->assert($updatedRow = $exp, "Test->export() failed: " . var_export($exp, 1));
$newname = 'test updated again';
$tr->name = $newname;
$save = $tr->save();
$this->assert($save, "Test->save() failed: " . var_export($tr->getErrorList(), 1));
$this->assert(Test::count() == 1, "Test::count() failed");
$tr->name = null;
$this->assert(!$tr->save(), "Test->save() should have failed (required name rule should fail)!");
$tr->name = array('123');
$this->assert(!$tr->save(), "Test->save() should have failed (string name rule should fail)!");
$tr2 = new Test();
$tr2->name = '000 second row';
// three zeroes - to ensure it sorts above the first one
$this->assert($tr2->save(), 'Test->save() failed: ' . var_export($tr->getErrorList(), 1));
$s = Test::findAll();
$s->setOrder('name');
$s->paginate(1, 1);
$all = $s->export()->fetchAll();
$this->assert(1 == count($all), 'Select->count() failed after pagination');
$this->assert($tr2->name == $all[0]->name, 'Select->export() failed ordering');
}
示例2: actionIndex
function actionIndex()
{
$objects = Test::findAll();
$this->render('index', array('data' => $objects));
}