예제 #1
1
파일: Fun.php 프로젝트: xandros15/Saya-Bot
 protected function iroha(array $arguments)
 {
     parent::RedBeanConnect('xandrosmaker_cba_pl');
     $relese = R::findLast('relki', 'where `seria` LIKE ? AND  `ep` = ?', ['%Iroha%', (int) $arguments[0]]);
     $message = $relese ? 'Prosze: ' . $relese->link : 'Jeszcze jej nie mam, ale lap w zamian ladny ending: http://exsubs.anidb.pl/?wpfb_dl=28';
     $this->message($message, $this->bot->getUserNick(), IRC::NOTICE);
     R::close();
 }
예제 #2
0
 function getLast($clientid)
 {
     $menu = R::findLast('menu', "client_id = ?", array($clientid));
     return $menu->export();
 }
예제 #3
0
 /**
  * Begin testing.
  * This method runs the actual test pack.
  * 
  * @return void
  */
 public function testFinding()
 {
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $a = new RedBean_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 RedBean_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 (RedBean_Exception_Security $exception) {
         pass();
     }
 }