本文整理汇总了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;
}
示例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()));
}
示例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;
}
示例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;
}
示例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;
}
}
}
}
}