当前位置: 首页>>代码示例>>PHP>>正文


PHP Facade::find方法代码示例

本文整理汇总了PHP中RedBeanPHP\Facade::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Facade::find方法的具体用法?PHP Facade::find怎么用?PHP Facade::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在RedBeanPHP\Facade的用法示例。


在下文中一共展示了Facade::find方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  * Logs admin into the system
  * @param $login
  * @param $password
  * @return \SkullyAdmin\Models\Admin|null
  */
 public function login($login, $password)
 {
     /** @var \RedBean_SimpleModel $adminBean */
     $adminBean = R::findOne('admin', "status = ? and email = ?", array(Admin::STATUS_ACTIVE, $login));
     if (!empty($adminBean)) {
         /** @var \SkullyAdmin\Models\Admin $admin */
         $admin = $adminBean->box();
         if ($admin->get('password_hash') == UtilitiesHelper::toHash($password, $admin->get('salt'), $this->app->config('globalSalt'))) {
             $adminSessions = R::find('adminsession', "admin_id = ?", array($admin->getID()));
             if (!empty($adminSessions)) {
                 R::trashAll($adminSessions);
             }
             // when everything ok, regenerate session
             session_regenerate_id(true);
             // change session ID for the current session and invalidate old session ID
             $adminId = $admin->getID();
             $sessionId = session_id();
             $adminsession = $this->app->createModel('adminsession', array("admin_id" => $adminId, "session_id" => $sessionId));
             $this->app->getSession()->set('adminId', $admin->getID());
             R::store($adminsession);
             return $admin;
         }
     }
     return null;
 }
开发者ID:skullyframework,项目名称:skully-admin,代码行数:31,代码来源:AdminRepository.php

示例2: testIssue259

 /**
  * Test to make sure stash cache works with recursively opening models
  * with FUSE.
  *
  * @return void
  */
 public function testIssue259()
 {
     testpack('Testing Issue #259 - Stash Cache breaks model delegation in open().');
     $mother = R::dispense('mother');
     $mother->desc = 'I am mother';
     R::store($mother);
     $child = R::dispense('child');
     $child->mother = $mother;
     $child->desc = 'I am child';
     $id = R::store($child);
     R::findOne('child', ' id = ?', array($id));
     R::find('child', ' id = ? ', array($id));
     R::load('child', $id);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:20,代码来源:Issue259.php

示例3: testExportIssue

 /**
  * In the past it was not possible to export beans
  * like 'feed' (Model_Feed).
  *
  * @return void
  */
 public function testExportIssue()
 {
     R::nuke();
     $feed = R::dispense('feed');
     $feed->post = array('first', 'second');
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second"]');
     $feed = $feed->fresh();
     asrt(is_array($feed->post), TRUE);
     asrt($feed->post[0], 'first');
     asrt($feed->post[1], 'second');
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second"]');
     $feed = R::load('feed', $feed->id);
     $feed->post[] = 'third';
     R::store($feed);
     $rows = R::getAll('SELECT * FROM feed');
     asrt($rows[0]['post'], '["first","second","third"]');
     $feed = $feed->fresh();
     asrt(is_array($feed->post), TRUE);
     asrt($feed->post[0], 'first');
     asrt($feed->post[1], 'second');
     asrt($feed->post[2], 'third');
     //now the catch: can we use export?
     //PHP Fatal error:  Call to a member function export() on a non-object
     $feeds = R::exportAll(R::find('feed'));
     asrt(is_array($feeds), TRUE);
     $feed = reset($feeds);
     asrt($feed['post'][0], 'first');
     asrt($feed['post'][1], 'second');
     asrt($feed['post'][2], 'third');
     //can we also dup()?
     $feedOne = R::findOne('feed');
     R::store(R::dup($feedOne));
     asrt(R::count('feed'), 2);
     //can we delete?
     R::trash($feedOne);
     asrt(R::count('feed'), 1);
     $feedTwo = R::findOne('feed');
     $feed = $feedTwo->export();
     asrt($feed['post'][0], 'first');
     asrt($feed['post'][1], 'second');
     asrt($feed['post'][2], 'third');
 }
开发者ID:diego-vieira,项目名称:redbean,代码行数:52,代码来源:Issue408.php

示例4: testCachingEffects

 /**
  * Test effects of cache.
  * 
  * @return void
  */
 public function testCachingEffects()
 {
     testpack('Testing WriteCache Query Writer Cache');
     R::useWriterCache(FALSE);
     R::debug(true, 1);
     $logger = R::getDatabaseAdapter()->getDatabase()->getLogger();
     $book = R::dispense('book')->setAttr('title', 'ABC');
     $book->ownPage[] = R::dispense('page');
     $id = R::store($book);
     // Test load cache -- without
     $logger->clear();
     $book = R::load('book', $id);
     $book = R::load('book', $id);
     asrt(count($logger->grep('SELECT')), 2);
     // With cache
     R::useWriterCache(TRUE);
     $logger->clear();
     $book = R::load('book', $id);
     $book = R::load('book', $id);
     asrt(count($logger->grep('SELECT')), 1);
     R::useWriterCache(FALSE);
     // Test find cache
     $logger->clear();
     $book = R::find('book');
     $book = R::find('book');
     asrt(count($logger->grep('SELECT')), 2);
     // With cache
     R::getWriter()->setUseCache(TRUE);
     $logger->clear();
     $book = R::find('book');
     $book = R::find('book');
     asrt(count($logger->grep('SELECT')), 1);
     R::getWriter()->setUseCache(FALSE);
     // Test combinations
     $logger->clear();
     $book = R::findOne('book', ' id = ? ', array($id));
     $book->ownPage;
     R::batch('book', array($id));
     $book = R::findOne('book', ' id = ? ', array($id));
     $book->ownPage;
     R::batch('book', array($id));
     asrt(count($logger->grep('SELECT')), 6);
     // With cache
     R::getWriter()->setUseCache(TRUE);
     $logger->clear();
     R::batch('book', array($id));
     $book = R::findOne('book', ' id = ? ', array($id));
     $book->ownPage;
     $book = R::findOne('book', ' id = ? ', array($id));
     $book->ownPage;
     asrt(count($logger->grep('SELECT')), 3);
     R::getWriter()->setUseCache(FALSE);
     // Test auto flush
     $logger->clear();
     $book = R::findOne('book');
     $book->name = 'X';
     R::store($book);
     $book = R::findOne('book');
     asrt(count($logger->grep('SELECT *')), 2);
     // With cache
     R::getWriter()->setUseCache(TRUE);
     $logger->clear();
     $book = R::findOne('book');
     $book->name = 'Y';
     // Will flush
     R::store($book);
     $book = R::findOne('book');
     // Now the same, auto flushed
     asrt(count($logger->grep('SELECT *')), 2);
     R::getWriter()->setUseCache(FALSE);
     // Test whether delete flushes as well (because uses selectRecord - might be a gotcha!)
     R::store(R::dispense('garbage'));
     $garbage = R::findOne('garbage');
     $logger->clear();
     $book = R::findOne('book');
     R::trash($garbage);
     $book = R::findOne('book');
     asrt(count($logger->grep('SELECT *')), 2);
     R::store(R::dispense('garbage'));
     $garbage = R::findOne('garbage');
     // With cache
     R::getWriter()->setUseCache(TRUE);
     $logger->clear();
     $book = R::findOne('book');
     R::trash($garbage);
     $book = R::findOne('book');
     // Now the same, auto flushed
     asrt(count($logger->grep('SELECT *')), 2);
     R::getWriter()->setUseCache(FALSE);
     R::store(R::dispense('garbage'));
     $garbage = R::findOne('garbage');
     // With cache
     R::getWriter()->setUseCache(TRUE);
     $logger->clear();
     $book = R::findOne('book');
//.........这里部分代码省略.........
开发者ID:skullyframework,项目名称:skully,代码行数:101,代码来源:Writecache.php

示例5: testCommonUsageFacade

 /**
  * Test common Facade usage scenarios.
  *
  * @return void
  */
 public function testCommonUsageFacade()
 {
     $toolbox = R::getToolBox();
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $a = new AssociationManager($toolbox);
     asrt(R::getRedBean() instanceof OODB, TRUE);
     asrt(R::getToolBox() instanceof ToolBox, TRUE);
     asrt(R::getDatabaseAdapter() instanceof Adapter, TRUE);
     asrt(R::getWriter() instanceof QueryWriter, TRUE);
     $book = R::dispense("book");
     asrt($book instanceof OODBBean, TRUE);
     $book->title = "a nice book";
     $id = R::store($book);
     asrt($id > 0, TRUE);
     $book = R::load("book", (int) $id);
     asrt($book->title, "a nice book");
     asrt(R::load('book', 999)->title, NULL);
     R::freeze(TRUE);
     try {
         R::load('bookies', 999);
         fail();
     } catch (\Exception $e) {
         pass();
     }
     R::freeze(FALSE);
     $author = R::dispense("author");
     $author->name = "me";
     R::store($author);
     $book9 = R::dispense("book");
     $author9 = R::dispense("author");
     $author9->name = "mr Nine";
     $a9 = R::store($author9);
     $book9->author_id = $a9;
     $bk9 = R::store($book9);
     $book9 = R::load("book", $bk9);
     $author = R::load("author", $book9->author_id);
     asrt($author->name, "mr Nine");
     R::trash($author);
     R::trash($book9);
     pass();
     $book2 = R::dispense("book");
     $book2->title = "second";
     R::store($book2);
     $book3 = R::dispense("book");
     $book3->title = "third";
     R::store($book3);
     asrt(count(R::find("book")), 3);
     asrt(count(R::findAll("book")), 3);
     asrt(count(R::findAll("book", " LIMIT 2")), 2);
     asrt(count(R::find("book", " id=id ")), 3);
     asrt(count(R::find("book", " title LIKE ?", array("third"))), 1);
     asrt(count(R::find("book", " title LIKE ?", array("%d%"))), 2);
     // Find without where clause
     asrt(count(R::findAll('book', ' order by id')), 3);
     R::trash($book3);
     R::trash($book2);
     asrt(count(R::getAll("SELECT * FROM book ")), 1);
     asrt(count(R::getCol("SELECT title FROM book ")), 1);
     asrt((int) R::getCell("SELECT 123 "), 123);
     $book = R::dispense("book");
     $book->title = "not so original title";
     $author = R::dispense("author");
     $author->name = "Bobby";
     R::store($book);
     $aid = R::store($author);
     $author = R::findOne("author", " name = ? ", array("Bobby"));
 }
开发者ID:cesium147,项目名称:redbean,代码行数:75,代码来源:Facade.php

示例6: testFunctionFilters

 /**
  * Test Facade bind function method.
  * Test for MySQL WKT spatial format.
  */
 public function testFunctionFilters()
 {
     R::nuke();
     R::bindFunc('read', 'location.point', 'asText');
     R::bindFunc('write', 'location.point', 'GeomFromText');
     R::store(R::dispense('location'));
     R::freeze(true);
     try {
         R::find('location');
         fail();
     } catch (SQL $exception) {
         pass();
     }
     R::freeze(false);
     try {
         R::find('location');
         pass();
     } catch (SQL $exception) {
         fail();
     }
     $location = R::dispense('location');
     $location->point = 'POINT(14 6)';
     R::store($location);
     $columns = R::inspect('location');
     asrt($columns['point'], 'point');
     $location = $location->fresh();
     asrt($location->point, 'POINT(14 6)');
     R::nuke();
     $location = R::dispense('location');
     $location->point = 'LINESTRING(0 0,1 1,2 2)';
     R::store($location);
     $columns = R::inspect('location');
     asrt($columns['point'], 'linestring');
     $location->bustcache = 2;
     R::store($location);
     $location = $location->fresh();
     asrt($location->point, 'LINESTRING(0 0,1 1,2 2)');
     R::nuke();
     $location = R::dispense('location');
     $location->point = 'POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))';
     R::store($location);
     $columns = R::inspect('location');
     asrt($columns['point'], 'polygon');
     $location->bustcache = 4;
     R::store($location);
     $location = $location->fresh();
     asrt($location->point, 'POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))');
     R::bindFunc('read', 'location.point', NULL);
     $location->bustcache = 1;
     R::store($location);
     $location = $location->fresh();
     asrt($location->point === 'POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7,5 5))', FALSE);
     $filters = AQueryWriter::getSQLFilters();
     asrt(is_array($filters), TRUE);
     asrt(count($filters), 2);
     asrt(isset($filters[QueryWriter::C_SQLFILTER_READ]), TRUE);
     asrt(isset($filters[QueryWriter::C_SQLFILTER_WRITE]), TRUE);
     R::bindFunc('read', 'place.point', 'asText');
     R::bindFunc('write', 'place.point', 'GeomFromText');
     R::bindFunc('read', 'place.line', 'asText');
     R::bindFunc('write', 'place.line', 'GeomFromText');
     R::nuke();
     $place = R::dispense('place');
     $place->point = 'POINT(13.2 666.6)';
     $place->line = 'LINESTRING(9.2 0,3 1.33)';
     R::store($place);
     $columns = R::inspect('place');
     asrt($columns['point'], 'point');
     asrt($columns['line'], 'linestring');
     $place = R::findOne('place');
     asrt($place->point, 'POINT(13.2 666.6)');
     asrt($place->line, 'LINESTRING(9.2 0,3 1.33)');
     R::bindFunc('read', 'place.point', NULL);
     R::bindFunc('write', 'place.point', NULL);
     R::bindFunc('read', 'place.line', NULL);
     R::bindFunc('write', 'place.line', NULL);
 }
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:81,代码来源:Writer.php

示例7: accueil

function accueil()
{
    global $twig, $base, $titre;
    $personnes = R::find("personnes");
    return $twig->render("accueil.html", compact("base", "titre", "personnes"));
}
开发者ID:HE-Arc,项目名称:php-intro-framework,代码行数:6,代码来源:index.php

示例8: testSelfReferentialCRUD

 /**
  * Test many different scenarios with self referential
  * many-to-many relations.
  *
  * @return void
  */
 public function testSelfReferentialCRUD()
 {
     R::nuke();
     $buddies = R::dispense('buddy', 4);
     $buddies[0]->name = 'A';
     $buddies[1]->name = 'B';
     $buddies[2]->name = 'C';
     $buddies[3]->name = 'D';
     $buddies[0]->sharedBuddyList = array($buddies[1], $buddies[2]);
     $buddies[3]->sharedBuddyList = array($buddies[2]);
     R::storeAll($buddies);
     $buddies[0] = $buddies[0]->fresh();
     asrt(count($buddies[0]->sharedBuddyList), 2);
     //does this yield valid combinations - cross relations / self ref n-m
     //need to symmetric....
     $names = R::gatherLabels($buddies[0]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'B,C');
     unset($buddies[0]->sharedBuddy);
     R::storeAll($buddies);
     $buddies[0] = $buddies[0]->fresh();
     asrt(count($buddies[0]->sharedBuddyList), 2);
     $buddies[3] = $buddies[3]->fresh();
     asrt(count($buddies[3]->sharedBuddyList), 1);
     $names = R::gatherLabels($buddies[3]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'C');
     $buddies[2] = $buddies[2]->fresh();
     asrt(count($buddies[2]->sharedBuddyList), 2);
     $names = R::gatherLabels($buddies[2]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'A,D');
     $buddies[1] = $buddies[1]->fresh();
     asrt(count($buddies[1]->sharedBuddyList), 1);
     $names = R::gatherLabels($buddies[1]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'A');
     //Can we add one?
     $buddies[1]->sharedBuddyList[] = R::dispense('buddy')->setAttr('name', 'E');
     R::store($buddies[1]);
     $buddies[0] = $buddies[0]->fresh();
     asrt(count($buddies[0]->sharedBuddyList), 2);
     $names = R::gatherLabels($buddies[0]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'B,C');
     $buddies[1] = $buddies[1]->fresh();
     asrt(count($buddies[1]->sharedBuddyList), 2);
     $names = R::gatherLabels($buddies[1]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'A,E');
     $all = R::find('buddy');
     asrt(count($all), 5);
     foreach ($buddies[1]->sharedBuddy as $buddy) {
         if ($buddy->name === 'E') {
             $buddyE = $buddy;
         }
     }
     asrt(isset($buddyE), TRUE);
     asrt($buddyE->name, 'E');
     //can we update?
     foreach ($buddies[0]->sharedBuddy as $buddy) {
         if ($buddy->name === 'C') {
             $buddy->name = 'C2';
         }
     }
     R::store($buddies[0]);
     $buddies[0] = $buddies[0]->fresh();
     asrt(count($buddies[0]->sharedBuddyList), 2);
     $names = R::gatherLabels($buddies[0]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'B,C2');
     $buddies[2] = $buddies[2]->fresh();
     asrt(count($buddies[2]->sharedBuddyList), 2);
     $names = R::gatherLabels($buddies[2]->sharedBuddyList);
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'A,D');
     //can we delete?
     foreach ($buddies[0]->sharedBuddyList as $id => $buddy) {
         if ($buddy->name === 'B') {
             unset($buddies[0]->sharedBuddyList[$id]);
         }
     }
     R::store($buddies[0]);
     $buddies[0] = $buddies[0]->fresh();
     asrt(count($buddies[0]->sharedBuddyList), 1);
     $names = R::gatherLabels($buddies[0]->sharedBuddyList);
//.........这里部分代码省略.........
开发者ID:diego-vieira,项目名称:redbean,代码行数:101,代码来源:Cross.php

示例9: testFullSupport


//.........这里部分代码省略.........
     }
     asrt(!is_null($blueRoom), TRUE);
     asrt(is_array($blueRoom->sharedGhostList), TRUE);
     asrt(count($blueRoom->sharedGhostList), 3);
     $names = array();
     foreach ($blueRoom->sharedGhost as $ghost) {
         $names[] = $ghost->name;
     }
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'one,three,two');
     $rooms = $haunted->xownRoomList;
     $redRoom = NULL;
     foreach ($rooms as $room) {
         if ($room->name === 'Red Room') {
             $redRoom = $room;
             break;
         }
     }
     $names = array();
     foreach ($redRoom->sharedGhost as $ghost) {
         $names[] = $ghost->name;
     }
     sort($names);
     $names = implode(',', $names);
     asrt($names, 'two,zero');
     asrt(!is_null($redRoom), TRUE);
     asrt(is_array($redRoom->sharedGhostList), TRUE);
     asrt(count($redRoom->sharedGhostList), 2);
     //Can we repaint a room?
     $redRoom->name = 'Yellow Room';
     $id = R::store($redRoom);
     $yellowRoom = R::load('room', $id);
     asrt($yellowRoom->name, 'Yellow Room');
     asrt(!is_null($yellowRoom), TRUE);
     asrt(is_array($yellowRoom->sharedGhostList), TRUE);
     asrt(count($yellowRoom->sharedGhostList), 2);
     //Can we throw one ghost out?
     array_pop($yellowRoom->sharedGhost);
     R::store($yellowRoom);
     $yellowRoom = $yellowRoom->fresh();
     asrt($yellowRoom->name, 'Yellow Room');
     asrt(!is_null($yellowRoom), TRUE);
     asrt(is_array($yellowRoom->sharedGhostList), TRUE);
     asrt(count($yellowRoom->sharedGhostList), 1);
     //can we remove one of the rooms?
     asrt(R::count('key'), 1);
     $list = $mansion->withCondition(' "name" = ? ', array('Blue Room'))->xownRoomList;
     $room = reset($list);
     unset($mansion->xownRoomList[$room->id]);
     R::store($mansion);
     asrt(R::count('room'), 2);
     //and what about its dependent beans?
     asrt(R::count('key'), 0);
     asrt(R::count('ghost_room'), 3);
     //and can we find ghosts?
     $ghosts = R::find('ghost');
     asrt(count($ghosts), 4);
     $ghosts = R::findAll('ghost', 'ORDER BY id');
     asrt(count($ghosts), 4);
     $ghosts = R::findAll('ghost', 'ORDER BY id LIMIT 2');
     asrt(count($ghosts), 2);
     $ghostZero = R::findOne('ghost', ' "name" = ? ', array('zero'));
     asrt($ghostZero instanceof OODBBean, TRUE);
     //can we create link properties on existing tables?
     $blackRoom = R::dispense('room');
     $blackRoom->name = 'Black Room';
     $ghostZero->link('ghost_room', array('mood' => 'grumpy'))->room = $blackRoom;
     R::store($ghostZero);
     $ghostZero = $ghostZero->fresh();
     $list = $ghostZero->sharedRoomList;
     asrt(count($list), 3);
     $ghostZero = $ghostZero->fresh();
     $list = $ghostZero->withCondition(' ghost_room.mood = ? ', array('grumpy'))->sharedRoomList;
     asrt(count($list), 1);
     //can we load a batch?
     $ids = R::getCol('SELECT id FROM ghost');
     $ghosts = R::batch('ghost', $ids);
     asrt(count($ghosts), 4);
     //can we do an aggregation?
     $ghosts = $greenRoom->aggr('ownGhostRoom', 'ghost', 'ghost');
     asrt(count($ghosts), 2);
     //can we duplicate the mansion?
     asrt(R::count('mansion'), 1);
     asrt(R::count('room'), 3);
     asrt(R::count('ghost'), 4);
     $copy = R::dup($mansion);
     R::store($copy);
     asrt(R::count('mansion'), 2);
     asrt(R::count('room'), 5);
     //black room does not belong to mansion 1
     asrt(R::count('ghost'), 4);
     //can we do some counting using the list?
     asrt($copy->countOwn('room'), 2);
     $rooms = $copy->withCondition(' "name" = ? ', array('Green Room'))->xownRoomList;
     $room = reset($rooms);
     asrt($room->countShared('ghost'), 2);
     //Finally restore old toolbox
     R::configureFacadeWithToolbox($oldToolBox);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:101,代码来源:Uuid.php

示例10: deletePackageCost

function deletePackageCost($id)
{
    $packageCost = R::find('packagecost', 'id=?', [$id]);
    R::trashAll($packageCost);
}
开发者ID:pierrerispal,项目名称:ppe_gsb_API_cost_managment,代码行数:5,代码来源:api_function.php

示例11: getsystemlogs_paged

 /**
  * @param int $startIndex
  * @param int $numItems
  * @return array
  */
 public function getsystemlogs_paged($startIndex, $numItems, $userid = NULL)
 {
     try {
         $rows = R::find($this->tbname, ' LIMIT ? , ? ', array($startIndex, $numItems));
         $rows = R::prepareForAMF(R::convertBeanToArray($rows), array(0 => $this->tbname));
         return $rows;
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
 }
开发者ID:limweb,项目名称:webappservice,代码行数:15,代码来源:SystemlogsService.php

示例12: testFindError

 /**
  * Test error handling of SQL states.
  *
  * @return void
  */
 public function testFindError()
 {
     R::freeze(FALSE);
     $page = R::dispense('page');
     $page->title = 'abc';
     R::store($page);
     //Column does not exist, in fluid mode no error!
     try {
         R::find('page', ' xtitle = ? ', array('x'));
         pass();
     } catch (SQL $e) {
         fail();
     }
     //Table does not exist, in fluid mode no error!
     try {
         R::find('pagex', ' title = ? ', array('x'));
         pass();
     } catch (SQL $e) {
         fail();
     }
     //Syntax error, error in fluid mode if possible to infer from SQLSTATE (MySQL/Postgres)
     try {
         R::find('page', ' invalid SQL ');
         //In SQLite only get HY000 - not very descriptive so suppress more errors in fluid mode then.
         if ($this->currentlyActiveDriverID === 'sqlite' || $this->currentlyActiveDriverID === 'CUBRID') {
             pass();
         } else {
             fail();
         }
     } catch (SQL $e) {
         pass();
     }
     //Frozen, always error...
     R::freeze(TRUE);
     //Column does not exist, in frozen mode error!
     try {
         R::find('page', ' xtitle = ? ', array('x'));
         fail();
     } catch (SQL $e) {
         pass();
     }
     //Table does not exist, in frozen mode error!
     try {
         R::find('pagex', ' title = ? ', array('x'));
         fail();
     } catch (SQL $e) {
         pass();
     }
     //Syntax error, in frozen mode error!
     try {
         R::find('page', ' invalid SQL ');
         fail();
     } catch (SQL $e) {
         pass();
     }
     R::freeze(FALSE);
 }
开发者ID:cesium147,项目名称:redbean,代码行数:62,代码来源:Finding.php

示例13: ExportWithFilters

 /**
  * Test exporting with filters.
  *
  * @return void
  */
 public function ExportWithFilters()
 {
     testpack('Export with filters');
     $book = R::dispense('book');
     $pages = R::dispense('page', 2);
     $texts = R::dispense('text', 2);
     $images = R::dispense('image', 2);
     $author = R::dispense('author');
     $pub = R::dispense('publisher');
     $bookmarks = R::dispense('bookmark', 2);
     $pages[0]->ownText = array($texts[0]);
     $pages[0]->ownImage = array($images[0]);
     $pages[1]->ownText = array($texts[1]);
     $pages[1]->ownImage = array($images[1]);
     $pages[0]->sharedBookmark[] = $bookmarks[0];
     $pages[1]->sharedBookmark[] = $bookmarks[1];
     $bookmarks[0]->ownNote[] = R::dispense('note')->setAttr('text', 'a note');
     $bookmarks[1]->ownNote[] = R::dispense('note')->setAttr('text', 'a note');
     $book->ownPage = $pages;
     $book->author = $author;
     $author->publisher = $pub;
     $bookID = R::store($book);
     R::getDuplicationManager()->setTables(R::getWriter()->getTables());
     $objects = R::exportAll(array($book), TRUE, array());
     asrt(isset($objects[0]['ownPage']), TRUE);
     asrt(count($objects[0]['ownPage']), 2);
     asrt(isset($objects[0]['author']), TRUE);
     asrt(isset($objects[0]['ownPage'][0]['ownText']), TRUE);
     asrt(count($objects[0]['ownPage'][0]['ownText']), 1);
     asrt(isset($objects[0]['ownPage'][0]['ownImage']), TRUE);
     asrt(count($objects[0]['ownPage'][0]['ownImage']), 1);
     $objects = R::exportAll(array($book), TRUE, array('page', 'author', 'text', 'image'));
     asrt(isset($objects[0]['ownPage']), TRUE);
     asrt(count($objects[0]['ownPage']), 2);
     asrt(isset($objects[0]['author']), TRUE);
     asrt(isset($objects[0]['ownPage'][0]['ownText']), TRUE);
     asrt(count($objects[0]['ownPage'][0]['ownText']), 1);
     asrt(isset($objects[0]['ownPage'][0]['ownImage']), TRUE);
     asrt(count($objects[0]['ownPage'][0]['ownImage']), 1);
     $objects = R::exportAll(array($book), TRUE, 'author');
     asrt(isset($objects[0]['ownPage']), FALSE);
     asrt(isset($objects[0]['ownPage'][0]['ownText']), FALSE);
     $objects = R::exportAll(array($book), TRUE, array('page'));
     asrt(isset($objects[0]['author']), FALSE);
     asrt(isset($objects[0]['ownPage'][0]['ownText']), FALSE);
     $objects = R::exportAll(array($book), TRUE, array('page', 'text'));
     asrt(isset($objects[0]['author']), FALSE);
     asrt(isset($objects[0]['ownPage']), TRUE);
     asrt(isset($objects[0]['ownPage'][0]['ownText']), TRUE);
     asrt(count($objects[0]['ownPage'][0]['ownText']), 1);
     asrt(isset($objects[0]['ownPage'][0]['ownImage']), FALSE);
     $objects = R::exportAll(array($book), TRUE, array('none'));
     asrt(isset($objects[0]['author']), FALSE);
     asrt(isset($objects[0]['ownPage']), FALSE);
     $texts = R::find('text');
     R::getDuplicationManager()->setCacheTables(FALSE);
     testpack('Keyless export');
     $book = R::load('book', $bookID);
     $book->ownPage;
     $export = $book->export();
     asrt(isset($export['ownPage'][0]), TRUE);
 }
开发者ID:gabordemooij,项目名称:redbean,代码行数:67,代码来源:Dup.php

示例14: array

    $lines = R::exportAll(R::find('line', 'WHERE start_point_id=' . $city[0]['id']));
    $timetableCityDay = array();
    foreach ($lines as $line) {
        $timetable = R::exportAll(R::find('timetable', 'WHERE line_id=' . $line['id'] . ' AND day=' . $day));
        var_dump($timetable);
        if (!empty($timetable)) {
            $timetableCityDay[] = array($timetable[0]['start_time'], $line['end_point_id']);
        }
    }
    echo json_encode($timetableCityDay);
});
//return all the cities with coordinates
$app->get('/city', function () {
    $city = R::exportAll(R::find('city'));
    echo json_encode($city);
});
//Return line,price,start_time and distance by name city departure and name city arrival
$app->get('/nextStart/:cityNameDeparture/:cityNameArrival', function ($cityNameDeparture, $cityNameArrival) {
    $cityDeparture = R::exportAll(R::find('city', 'WHERE name="' . $cityNameDeparture . '"'));
    $cityArrival = R::exportAll(R::find('city', 'WHERE name="' . $cityNameArrival . '"'));
    $lines = R::exportAll(R::find('line', 'WHERE start_point_id=' . $cityDeparture[0]['id'] . ' AND end_point_id=' . $cityArrival[0]['id']));
    $timetableTrip = array();
    foreach ($lines as $line) {
        $timetable = R::exportAll(R::find('timetable', 'WHERE line_id=' . $line['id']));
        if (!empty($timetable)) {
            $timetableTrip[] = array($timetable[0]['start_time'], $line['price'], $line['distance'], $line['end_point_id']);
        }
    }
    echo json_encode($timetableTrip);
});
$app->run();
开发者ID:benjaminbra,项目名称:ApiGoBus,代码行数:31,代码来源:index.php


注:本文中的RedBeanPHP\Facade::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。