示例#1
0
文件: rb.php 项目: tejdeeps/tejcs.com
 /**
  * Wipes all beans of type $beanType.
  *
  * @param string $beanType type of bean you want to destroy entirely.
  */
 public static function wipe($beanType)
 {
     return RedBean_Facade::$redbean->wipe($beanType);
 }
 /**
  * Wipes all beans of type $beanType.
  *
  * @param string $beanType type of bean you want to destroy entirely
  *
  * @return boolean
  */
 public function wipe($beanType)
 {
     return $this->redbean->wipe($beanType);
 }
示例#3
0
	/**
	 * Wipes all beans of type $beanType.
	 *
	 * @param string $beanType type of bean you want to destroy entirely.
	 */
	public static function wipe( $beanType ) {
		R::$redbean->wipe($beanType);
	}
示例#4
0
 /**
  * Wipes all beans of type $beanType.
  *
  * @param string $beanType type of bean you want to destroy entirely
  *
  * @return boolean
  */
 public static function wipe($beanType)
 {
     return self::$redbean->wipe($beanType);
 }
 /**
  * Test the database driver and low level functions.
  * 
  * @return void
  */
 public function testDriver()
 {
     $currentDriver = $this->currentlyActiveDriverID;
     R::store(R::dispense('justabean'));
     $adapter = new TroubleDapter(R::$toolbox->getDatabaseAdapter()->getDatabase());
     $adapter->setSQLState('HY000');
     $writer = new RedBean_QueryWriter_SQLiteT($adapter);
     $redbean = new RedBean_OODB($writer);
     $toolbox = new RedBean_ToolBox($redbean, $adapter, $writer);
     // We can only test this for a known driver...
     if ($currentDriver === 'sqlite') {
         try {
             $redbean->find('bean');
             pass();
         } catch (Exception $e) {
             var_dump($e->getSQLState());
             fail();
         }
     }
     $adapter->setSQLState(-999);
     try {
         $redbean->find('bean');
         fail();
     } catch (Exception $e) {
         pass();
     }
     $beanA = R::dispense('bean');
     $beanB = R::dispense('bean');
     R::storeAll(array($beanA, $beanB));
     $associationManager = new RedBean_AssociationManager($toolbox);
     $adapter->setSQLState('HY000');
     // We can only test this for a known driver...
     if ($currentDriver === 'sqlite') {
         try {
             $associationManager->areRelated($beanA, $beanB);
             pass();
         } catch (Exception $e) {
             fail();
         }
     }
     $adapter->setSQLState(-999);
     try {
         $associationManager->areRelated($beanA, $beanA);
         fail();
     } catch (Exception $e) {
         pass();
     }
     try {
         $redbean->wipe('justabean');
         fail();
     } catch (Exception $e) {
         pass();
     }
     $toolbox = R::$toolbox;
     $adapter = $toolbox->getDatabaseAdapter();
     $writer = $toolbox->getWriter();
     $redbean = $toolbox->getRedBean();
     $pdo = $adapter->getDatabase();
     $page = $redbean->dispense("page");
     try {
         $adapter->exec("an invalid query");
         fail();
     } catch (RedBean_Exception_SQL $e) {
         pass();
     }
     // Special data type description should result in magic number 99 (specified)
     if ($currentDriver == 'mysql') {
         asrt($writer->code(RedBean_QueryWriter_MySQL::C_DATATYPE_SPECIAL_DATE), 99);
     }
     if ($currentDriver == 'pgsql') {
         asrt($writer->code(RedBean_QueryWriter_PostgreSQL::C_DATATYPE_SPECIAL_DATE), 99);
     }
     if ($currentDriver == 'CUBRID') {
         asrt($writer->code(RedBean_QueryWriter_CUBRID::C_DATATYPE_SPECIAL_DATE), 99);
     }
     asrt((int) $adapter->getCell("SELECT 123"), 123);
     $page->aname = "my page";
     $id = (int) $redbean->store($page);
     asrt((int) $page->id, 1);
     asrt((int) $pdo->GetCell("SELECT count(*) FROM page"), 1);
     asrt($pdo->GetCell("SELECT aname FROM page LIMIT 1"), "my page");
     asrt((int) $id, 1);
     $page = $redbean->load("page", 1);
     asrt($page->aname, "my page");
     asrt((bool) $page->getMeta("type"), TRUE);
     asrt(isset($page->id), TRUE);
     asrt($page->getMeta("type"), "page");
     asrt((int) $page->id, $id);
 }