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


PHP Selection::getPrimary方法代碼示例

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


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

示例1: getCount

 /**
  * @return int
  */
 public function getCount()
 {
     if ($this->count === NULL) {
         $column = !$this->source->getPrimary(FALSE) ? '*' : $this->source->getPrimary();
         $this->count = $this->source->count($column);
     }
     return $this->count;
 }
開發者ID:WebChemistry,項目名稱:filter,代碼行數:11,代碼來源:NetteDataSource.php

示例2: getCount

 /**
  * Get count of data
  * @return int
  */
 public function getCount()
 {
     try {
         $primary = $this->data_source->getPrimary();
     } catch (\LogicException $e) {
         return $this->data_source->count('*');
     }
     return $this->data_source->count($this->data_source->getName() . '.' . (is_array($primary) ? reset($primary) : $primary));
 }
開發者ID:ublaboo,項目名稱:datagrid,代碼行數:13,代碼來源:NetteDatabaseTableDataSource.php

示例3: access

 /**
  * @internal
  */
 public function access($key, $cache = TRUE)
 {
     if ($this->table->getConnection()->getCache() && !isset($this->modified[$key]) && $this->table->access($key, $cache)) {
         $id = isset($this->data[$this->table->getPrimary()]) ? $this->data[$this->table->getPrimary()] : $this->data;
         $this->data = $this->table[$id]->data;
     }
 }
開發者ID:JanVoracek,項目名稱:nette,代碼行數:10,代碼來源:ActiveRow.php

示例4: related

 /**
  * Returns referencing rows.
  * @param  string
  * @param  string
  * @return GroupedSelection
  */
 public function related($key, $throughColumn = NULL)
 {
     $groupedSelection = $this->table->getReferencingTable($key, $throughColumn, $this[$this->table->getPrimary()]);
     if (!$groupedSelection) {
         throw new Nette\MemberAccessException("No reference found for \${$this->table->name}->related({$key}).");
     }
     return $groupedSelection;
 }
開發者ID:vladimirslevercz,項目名稱:alena,代碼行數:14,代碼來源:ActiveRow.php

示例5: related

 /**
  * Returns referencing rows.
  * @param  string
  * @param  string
  * @return GroupedSelection
  */
 public function related($key, $throughColumn = NULL)
 {
     if (strpos($key, '.') !== FALSE) {
         list($key, $throughColumn) = explode('.', $key);
     } elseif (!$throughColumn) {
         list($key, $throughColumn) = $this->table->getConnection()->getDatabaseReflection()->getHasManyReference($this->table->getName(), $key);
     }
     return $this->table->getReferencingTable($key, $throughColumn, $this[$this->table->getPrimary()]);
 }
開發者ID:vrtak-cz,項目名稱:nette-doctrine-sandbox,代碼行數:15,代碼來源:ActiveRow.php

示例6: update

 /**
  * Updates row.
  * @param  array|\Traversable (column => value)
  * @return bool
  */
 public function update($data)
 {
     if ($data instanceof \Traversable) {
         $data = iterator_to_array($data);
     }
     $primary = $this->getPrimary();
     if (!is_array($primary)) {
         $primary = [$this->table->getPrimary() => $primary];
     }
     $selection = $this->table->createSelectionInstance()->wherePrimary($primary);
     if ($selection->update($data)) {
         if ($tmp = array_intersect_key($data, $primary)) {
             $selection = $this->table->createSelectionInstance()->wherePrimary($tmp + $primary);
         }
         $selection->select('*');
         if (($row = $selection->fetch()) === FALSE) {
             throw new Nette\InvalidStateException('Database refetch failed; row does not exist!');
         }
         $this->data = $row->data;
         return TRUE;
     } else {
         return FALSE;
     }
 }
開發者ID:ricco24,項目名稱:database,代碼行數:29,代碼來源:ActiveRow.php

示例7: delete

 /**
  * Deletes row.
  *
  * @return int number of affected rows or FALSE in case of an error
  */
 public function delete()
 {
     return $this->table->getConnection()->table($this->table->getName())->where($this->table->getPrimary(), $this[$this->table->getPrimary()])->delete();
 }
開發者ID:TheTypoMaster,項目名稱:SPHERE-Framework,代碼行數:9,代碼來源:ActiveRow.php

示例8: getPrimary

 /**
  * @param  bool
  * @return string|array|NULL
  *
  * @throws \LogicException
  */
 public function getPrimary($need = TRUE)
 {
     return $this->selection->getPrimary($need);
 }
開發者ID:filsedla,項目名稱:hyperrow,代碼行數:10,代碼來源:HyperSelection.php


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