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


PHP Grid::primaryKey方法代碼示例

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


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

示例1: scanForInsertId

 protected function scanForInsertId(Grid $grid)
 {
     if (!$grid->isLoaded()) {
         $primaryKey = $grid->primaryKey();
         $foundKeyColumn = false;
         if (is_array($primaryKey)) {
             foreach ($primaryKey as $keyColumn) {
                 if (!$keyColumn->isGeneratedOnPublish() || $keyColumn->hasData()) {
                     continue;
                 }
                 $foundKeyColumn = $keyColumn;
                 break;
             }
         } else {
             if ($primaryKey->isGeneratedOnPublish() && !$primaryKey->hasData()) {
                 $foundKeyColumn = $primaryKey;
             }
         }
         if ($foundKeyColumn) {
             $result = $this->query('SELECT SCOPE_IDENTITY() AS [LAST_INSERT_ID]');
             if (!$result || mssql_num_rows($result) != 1) {
                 $this->throwException('Attempt to fetch last insert id value failed: ' . $this->error());
             }
             $dataRow = $this->fetch_row($result);
             $foundKeyColumn->setData(array_shift($dataRow));
         }
     }
 }
開發者ID:codegooglecom,項目名稱:torpor-php,代碼行數:28,代碼來源:MSSQLDataStore.php

示例2: scanForInsertId

 protected function scanForInsertId(Grid $grid)
 {
     if (!$grid->isLoaded()) {
         $primaryKey = $grid->primaryKey();
         $foundKeyColumn = false;
         if (is_array($primaryKey)) {
             foreach ($primaryKey as $keyColumn) {
                 if (!$keyColumn->isGeneratedOnPublish() || $keyColumn->hasData()) {
                     continue;
                 }
                 $foundKeyColumn = $keyColumn;
                 break;
             }
         } else {
             if ($primaryKey->isGeneratedOnPublish() && !$primaryKey->hasData()) {
                 $foundKeyColumn = $primaryKey;
             }
         }
         if ($foundKeyColumn && ($lastInsertId = sqlite_last_insert_rowid($this->getConnection()))) {
             $foundKeyColumn->setData($lastInsertId);
         }
     }
 }
開發者ID:codegooglecom,項目名稱:torpor-php,代碼行數:23,代碼來源:SQLiteDataStore.php

示例3: scanForInsertId

 protected function scanForInsertId(Grid $grid, $sequence, $next = true)
 {
     if (!$grid->isLoaded()) {
         $primaryKey = $grid->primaryKey();
         $foundKeyColumn = false;
         if (is_array($primaryKey)) {
             foreach ($primaryKey as $keyColumn) {
                 if (!$keyColumn->isGeneratedOnPublish() || $keyColumn->hasData()) {
                     continue;
                 }
                 $foundKeyColumn = $keyColumn;
                 break;
             }
         } else {
             if ($primaryKey->isGeneratedOnPublish() && !$primaryKey->hasData()) {
                 $foundKeyColumn = $primaryKey;
             }
         }
         if ($foundKeyColumn) {
             $result = $this->query('SELECT ' . $this->escapeDataName($sequence) . '.' . $this->escapeDataName($next ? 'NEXTVAL' : 'CURRVAL') . ' ' . $this->asColumnOperator . ' ' . $this->escapeDataNameAlias('LAST_INSERT_ID') . ' FROM ' . $this->escapeDataName('DUAL'));
             if (!is_resource($result)) {
                 $this->throwException('Attempt to fetch last insert id value failed: ' . $this->error());
             }
             $dataRow = $this->fetch_row($result);
             $foundKeyColumn->setData(array_shift($dataRow));
         }
     }
 }
開發者ID:codegooglecom,項目名稱:torpor-php,代碼行數:28,代碼來源:OracleDataStore.php

示例4: scanForInsertId

 protected function scanForInsertId(Grid $grid)
 {
     if (!$grid->isLoaded()) {
         $primaryKey = $grid->primaryKey();
         $foundKeyColumn = false;
         if (is_array($primaryKey)) {
             foreach ($primaryKey as $keyColumn) {
                 if (!$keyColumn->isGeneratedOnPublish() || $keyColumn->hasData()) {
                     continue;
                 }
                 $foundKeyColumn = $keyColumn;
                 break;
             }
         } else {
             if ($primaryKey instanceof Column && $primaryKey->isGeneratedOnPublish() && !$primaryKey->hasData()) {
                 $foundKeyColumn = $primaryKey;
             }
         }
         if ($foundKeyColumn && in_array($foundKeyColumn->getType(), array(Column::TYPE_FLOAT, Column::TYPE_INTEGER, Column::TYPE_UNSIGNED_INTEGER))) {
             // Executing the query directly, since the mysql_insert_id() command casts the return
             // value to c(long), and may truncate.
             $result = $this->query('SELECT LAST_INSERT_ID()');
             if (!$result || $this->num_rows($result) != 1) {
                 $this->throwException('Attempt to fetch last insert id value failed: ' . $this->error());
             }
             $dataRow = $this->fetch_row($result);
             $foundKeyColumn->setData(array_shift($dataRow));
         }
     }
 }
開發者ID:codegooglecom,項目名稱:torpor-php,代碼行數:30,代碼來源:MySQLDataStore.php


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