當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DboSource::resetSequence方法代碼示例

本文整理匯總了PHP中DboSource::resetSequence方法的典型用法代碼示例。如果您正苦於以下問題:PHP DboSource::resetSequence方法的具體用法?PHP DboSource::resetSequence怎麽用?PHP DboSource::resetSequence使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DboSource的用法示例。


在下文中一共展示了DboSource::resetSequence方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testResetSequence

 public function testResetSequence()
 {
     $model = new Article();
     $table = $this->Dbo->fullTableName($model, false);
     $fields = array('id', 'user_id', 'title', 'body', 'published');
     $values = array(array(1, 1, 'test', 'first post', false), array(2, 1, 'test 2', 'second post post', false));
     $this->Dbo->insertMulti($table, $fields, $values);
     $sequence = $this->Dbo->getSequence($table);
     $result = $this->Dbo->rawQuery("SELECT nextval('{$sequence}')");
     $original = $result->fetch(PDO::FETCH_ASSOC);
     $this->assertTrue($this->Dbo->resetSequence($table, 'id'));
     $result = $this->Dbo->rawQuery("SELECT currval('{$sequence}')");
     $new = $result->fetch(PDO::FETCH_ASSOC);
     $this->assertTrue($new['currval'] > $original['nextval'], 'Sequence did not update');
 }
開發者ID:jeffersongoncalves,項目名稱:estudos,代碼行數:15,代碼來源:PostgresTest.php

示例2: insert

 /**
  * Run before each tests is executed, should return a set of SQL statements to insert records for the table
  * of this fixture could be executed successfully.
  *
  * @param DboSource $db An instance of the database into which the records will be inserted
  * @return boolean on success or if there are no records to insert, or false on failure
  */
 public function insert($db)
 {
     if (!isset($this->_insert)) {
         $values = array();
         if (isset($this->records) && !empty($this->records)) {
             $fields = array();
             foreach ($this->records as $record) {
                 $fields = array_merge($fields, array_keys(array_intersect_key($record, $this->fields)));
             }
             $fields = array_unique($fields);
             $default = array_fill_keys($fields, null);
             foreach ($this->records as $record) {
                 $fields = array_keys($record);
                 $values[] = array_values(array_merge($default, $record));
             }
             $nested = $db->useNestedTransactions;
             $db->useNestedTransactions = false;
             $result = $db->insertMulti($this->table, $fields, $values);
             if ($this->primaryKey && in_array($this->fields[$this->primaryKey]['type'], array('integer', 'biginteger'))) {
                 $db->resetSequence($this->table, $this->primaryKey);
             }
             $db->useNestedTransactions = $nested;
             return $result;
         }
         return true;
     }
 }
開發者ID:byu-oit-appdev,項目名稱:student-ratings,代碼行數:34,代碼來源:CakeTestFixture.php

示例3: insert

 /**
  * Run before each tests is executed, should return a set of SQL statements to insert records for the table
  * of this fixture could be executed successfully.
  *
  * @param DboSource $db An instance of the database into which the records will be inserted
  * @return bool on success or if there are no records to insert, or false on failure
  * @throws CakeException if counts of values and fields do not match.
  */
 public function insert($db)
 {
     if (!isset($this->_insert)) {
         $values = array();
         if (isset($this->records) && !empty($this->records)) {
             $fields = array();
             foreach ($this->records as $record) {
                 $fields = array_merge($fields, array_keys(array_intersect_key($record, $this->fields)));
             }
             $fields = array_unique($fields);
             $default = array_fill_keys($fields, null);
             foreach ($this->records as $record) {
                 $merge = array_values(array_merge($default, $record));
                 if (count($fields) !== count($merge)) {
                     throw new CakeException('Fixture invalid: Count of fields does not match count of values in ' . get_class($this));
                 }
                 $values[] = $merge;
             }
             $nested = $db->useNestedTransactions;
             $db->useNestedTransactions = false;
             $result = $db->insertMulti($this->table, $fields, $values);
             if ($this->primaryKey && isset($this->fields[$this->primaryKey]['type']) && in_array($this->fields[$this->primaryKey]['type'], array('integer', 'biginteger'))) {
                 $db->resetSequence($this->table, $this->primaryKey);
             }
             $db->useNestedTransactions = $nested;
             return $result;
         }
         return true;
     }
 }
開發者ID:thanphong,項目名稱:do-an-tot-nghiep-project,代碼行數:38,代碼來源:CakeTestFixture.php

示例4: insert

 /**
  * Run before each tests is executed, should return a set of SQL statements to insert records for the table
  * of this fixture could be executed successfully.
  *
  * @param DboSource $db An instance of the database into which the records will be inserted
  *
  * @return bool on success or if there are no records to insert, or false on failure
  * @throws CakeException if counts of values and fields do not match.
  */
 public function insert($db)
 {
     if (!isset($this->_insert)) {
         $values = array();
         if (isset($this->records) && !empty($this->records)) {
             $fields = array();
             foreach ($this->records as $record) {
                 $fields = array_merge($fields, array_keys(array_intersect_key($record, $this->fields)));
             }
             $fields = array_unique($fields);
             $default = array_fill_keys($fields, NULL);
             foreach ($this->records as $record) {
                 $mergeData = array_merge($default, $record);
                 $merge = array_values($mergeData);
                 if (count($fields) !== count($merge)) {
                     $mergeFields = array_diff_key(array_keys($mergeData), $fields);
                     $message = 'Fixture invalid: Count of fields does not match count of values in ' . get_class($this) . "\n";
                     foreach ($mergeFields as $field) {
                         $message .= "The field '" . $field . "' is in the data fixture but not in the schema." . "\n";
                     }
                     throw new CakeException($message);
                 }
                 $values[] = $merge;
             }
             $nested = $db->useNestedTransactions;
             $db->useNestedTransactions = FALSE;
             $result = $db->insertMulti($this->table, $fields, $values);
             if ($this->primaryKey && isset($this->fields[$this->primaryKey]['type']) && in_array($this->fields[$this->primaryKey]['type'], array('integer', 'biginteger'))) {
                 $db->resetSequence($this->table, $this->primaryKey);
             }
             $db->useNestedTransactions = $nested;
             return $result;
         }
         return TRUE;
     }
 }
開發者ID:mrbadao,項目名稱:api-official,代碼行數:45,代碼來源:CakeTestFixture.php


注:本文中的DboSource::resetSequence方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。