本文整理汇总了PHP中RedBeanPHP\Facade::findLast方法的典型用法代码示例。如果您正苦于以下问题:PHP Facade::findLast方法的具体用法?PHP Facade::findLast怎么用?PHP Facade::findLast使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RedBeanPHP\Facade
的用法示例。
在下文中一共展示了Facade::findLast方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFinding
/**
* Begin testing.
* This method runs the actual test pack.
*
* @return void
*/
public function testFinding()
{
$toolbox = R::getToolBox();
$adapter = $toolbox->getDatabaseAdapter();
$writer = $toolbox->getWriter();
$redbean = $toolbox->getRedBean();
$pdo = $adapter->getDatabase();
$a = new AssociationManager($toolbox);
$page = $redbean->dispense("page");
$page->name = "John's page";
$idpage = $redbean->store($page);
$page2 = $redbean->dispense("page");
$page2->name = "John's second page";
$idpage2 = $redbean->store($page2);
$a->associate($page, $page2);
$pageOne = $redbean->dispense("page");
$pageOne->name = "one";
$pageMore = $redbean->dispense("page");
$pageMore->name = "more";
$pageEvenMore = $redbean->dispense("page");
$pageEvenMore->name = "evenmore";
$pageOther = $redbean->dispense("page");
$pageOther->name = "othermore";
set1toNAssoc($a, $pageOther, $pageMore);
set1toNAssoc($a, $pageOne, $pageMore);
set1toNAssoc($a, $pageOne, $pageEvenMore);
asrt(count($redbean->find("page", array(), " name LIKE '%more%' ", array())), 3);
asrt(count($redbean->find("page", array(), " name LIKE :str ", array(":str" => '%more%'))), 3);
asrt(count($redbean->find("page", array(), array(" name LIKE :str ", array(":str" => '%more%')))), 3);
asrt(count($redbean->find("page", array(), " name LIKE :str ", array(":str" => '%mxore%'))), 0);
asrt(count($redbean->find("page", array("id" => array(2, 3)))), 2);
$bean = $redbean->dispense("wine");
$bean->name = "bla";
for ($i = 0; $i < 10; $i++) {
$redbean->store($bean);
}
$redbean->find("wine", array("id" => 5));
// Finder:where call OODB::convertToBeans
$bean2 = $redbean->load("anotherbean", 5);
asrt($bean2->id, 0);
$keys = $adapter->getCol("SELECT id FROM page WHERE " . $writer->esc('name') . " LIKE '%John%'");
asrt(count($keys), 2);
$pages = $redbean->batch("page", $keys);
asrt(count($pages), 2);
$p = R::findLast('page');
pass();
$row = R::getRow('select * from page ');
asrt(is_array($row), TRUE);
asrt(isset($row['name']), TRUE);
// Test findAll -- should not throw an exception
asrt(count(R::findAll('page')) > 0, TRUE);
asrt(count(R::findAll('page', ' ORDER BY id ')) > 0, TRUE);
$beans = R::findOrDispense("page");
asrt(count($beans), 6);
asrt(is_null(R::findLast('nothing')), TRUE);
try {
R::find('bean', ' id > 0 ', 'invalid bindings argument');
fail();
} catch (RedException $exception) {
pass();
}
}
示例2: testTitleField
/**
* Let's consider it RedBeanPHP's bug to use with SQLite for now...
* todo: Fix SQLite bug
* @expectedException \RedBeanPHP\RedException\SQL
*/
public function testTitleField()
{
$this->migrate();
$news = R::dispense('bar');
$news->import(array('title' => 'test news', 'newscategory_id' => 1));
R::store($news);
$newsFound = R::findLast('bar');
$this->assertEquals('test news', $newsFound->title);
}