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


PHP CakeTestFixture::insert方法代码示例

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


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

示例1: insert

 /**
  * insert
  *
  * @param Object $db
  * @return array
  */
 public function insert($db)
 {
     $result = parent::insert($db);
     if ($result === true && $db instanceof Postgres) {
         $this->_fixSequence($db);
     }
     return $result;
 }
开发者ID:laiello,项目名称:plankonindia,代码行数:14,代码来源:CroogoTestFixture.php

示例2: insert

 /**
  * Inserts records in the database
  *
  * @param DboSource $db
  * @return boolean
  */
 public function insert($db)
 {
     if (isset($this->_insert)) {
         return true;
     }
     if (!empty($this->records)) {
         return parent::insert($db);
     }
     return (bool) $db->execute(file_get_contents($this->_getFilePath()));
 }
开发者ID:theplankmeister,项目名称:cakephp-fixturize,代码行数:16,代码来源:SQLTestFixture.php

示例3: insert

 /**
  * Inserts records in the database
  *
  * This will only happen if the underlying table is modified in any way or
  * does not exist with a hash yet.
  *
  * @param DboSource $db
  * @return boolean
  */
 public function insert($db)
 {
     if ($this->_tableUnmodified($db)) {
         return true;
     }
     if (!empty($this->records)) {
         if (empty($this->fields)) {
             $this->fields = $db->describe($this->table);
         }
         $result = parent::insert($db);
         static::$_tableHashes[$this->table] = $this->_hash($db);
         return $result;
     }
     $source = ConnectionManager::getDataSource($this->sourceConfig);
     $sourceTable = $source->fullTableName($this->table);
     $query = sprintf('TRUNCATE TABLE %s', $db->fullTableName($this->table));
     $db->execute($query, ['log' => false]);
     $query = sprintf('INSERT INTO %s SELECT * FROM %s', $db->fullTableName($this->table), $sourceTable);
     $db->execute($query, ['log' => false]);
     static::$_tableHashes[$this->table] = $this->_hash($db);
     return true;
 }
开发者ID:theplankmeister,项目名称:cakephp-fixturize,代码行数:31,代码来源:TableCopyTestFixture.php

示例4: insert

 /**
  * Recovers tree after insterting data. This way we only need to properly define
  * the parent_id's for each records
  *
  * @param object $db Instance of DB
  * @return boolean Success
  */
 public function insert(&$db)
 {
     $success = parent::insert($db);
     ClassRegistry::init('Ministry')->recover();
     return $success;
 }
开发者ID:styfle,项目名称:core,代码行数:13,代码来源:ministry_fixture.php

示例5: startController

 /**
  * Callback issued when a controller's action is about to be invoked through testAction().
  *
  * @param Controller $controller	Controller that's about to be invoked.
  * @param array $params	Additional parameters as sent by testAction().
  * @return void
  * @access public
  */
 function startController(&$controller, $params = array())
 {
     if (isset($params['fixturize']) && (is_array($params['fixturize']) && !empty($params['fixturize']) || $params['fixturize'] === true)) {
         if (!isset($this->db)) {
             $this->_initDb();
         }
         if ($controller->uses === false) {
             $list = array($controller->modelClass);
         } else {
             $list = is_array($controller->uses) ? $controller->uses : array($controller->uses);
         }
         $models = array();
         ClassRegistry::config(array('ds' => $params['connection']));
         foreach ($list as $name) {
             if (is_array($params['fixturize']) && in_array($name, $params['fixturize']) || $params['fixturize'] === true) {
                 if (class_exists($name) || App::import('Model', $name)) {
                     $object = ClassRegistry::init($name);
                     //switch back to specified datasource.
                     $object->setDataSource($params['connection']);
                     $db = ConnectionManager::getDataSource($object->useDbConfig);
                     $db->cacheSources = false;
                     $models[$object->alias] = array('table' => $object->table, 'model' => $object->alias, 'key' => strtolower($name));
                 }
             }
         }
         ClassRegistry::config(array('ds' => 'test_suite'));
         if (!empty($models) && isset($this->db)) {
             $this->_actionFixtures = array();
             foreach ($models as $model) {
                 $fixture = new CakeTestFixture($this->db);
                 $fixture->name = $model['model'] . 'Test';
                 $fixture->table = $model['table'];
                 $fixture->import = array('model' => $model['model'], 'records' => true);
                 $fixture->init();
                 $fixture->create($this->db);
                 $fixture->insert($this->db);
                 $this->_actionFixtures[] = $fixture;
             }
             foreach ($models as $model) {
                 $object = ClassRegistry::getObject($model['key']);
                 if ($object !== false) {
                     $object->setDataSource('test_suite');
                     $object->cacheSources = false;
                 }
             }
         }
     }
 }
开发者ID:evrard,项目名称:cakephp2x,代码行数:56,代码来源:cake_test_case.php


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