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


PHP Doctrine_Table::create方法代碼示例

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


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

示例1: get

 /**
  * Gets a record for given key
  *
  * There are two special cases:
  *
  * 1. if null is given as a key a new record is created and attached
  * at the end of the collection
  *
  * 2. if given key does not exist, then a new record is create and attached
  * to the given key
  *
  * Collection also maps referential information to newly created records
  *
  * @param mixed $key                    the key of the element
  * @return Doctrine_Record              return a specified record
  */
 public function get($key)
 {
     if (!isset($this->data[$key])) {
         $record = $this->_table->create();
         if (isset($this->referenceField)) {
             $value = $this->reference->get($this->relation->getLocalFieldName());
             if ($value !== null) {
                 $record->set($this->referenceField, $value, false);
             } else {
                 $record->set($this->referenceField, $this->reference, false);
             }
         }
         if ($key === null) {
             $this->data[] = $record;
         } else {
             $this->data[$key] = $record;
         }
         $this->oids[$record->oid()] = true;
         if (isset($this->keyColumn)) {
             $record->set($this->keyColumn, $key);
         }
         return $record;
     }
     return $this->data[$key];
 }
開發者ID:sabaki-dev,項目名稱:doctrine1,代碼行數:41,代碼來源:Collection.php

示例2: _write

 /**
  * Write Event to database
  *
  * @param  array  $event
  */
 public function _write($event)
 {
     $entry = $this->_table->create(array());
     foreach ($this->_columnMap as $eventIndex => $tableColumn) {
         $entry->{$tableColumn} = $event[$eventIndex];
     }
     $entry->save();
 }
開發者ID:robo47,項目名稱:robo47-components,代碼行數:13,代碼來源:DoctrineTable.php

示例3: create

 /**
  * Create a new lab
  * @param <type> $name
  * @return <type>
  */
 public function create($name)
 {
     if ($name == "") {
         throw new Exception(self::ERROR_INVALID_NAME);
     }
     $code_generator = new App_Value_Code();
     do {
         $code = $code_generator->get();
     } while ($this->db->findByCode($code)->count() != 0);
     $lab = $this->db->create();
     $lab->name = $name;
     $lab->code = $code;
     if ($lab->isValid()) {
         try {
             $lab->save();
         } catch (Exception $e) {
             throw new Exception(self::ERROR_NOT_SAVED);
         }
     } else {
         throw new Exception(self::ERROR_NOT_VALID . $lab->getErrorStackAsString());
     }
     return $lab->toArray();
 }
開發者ID:samuel-mccallum,項目名稱:Task-Lab,代碼行數:28,代碼來源:Lab.php

示例4: _write

 /**
  * Write a message to the log.
  *
  * @param  array  $event  event data
  * @return void
  */
 protected function _write($event)
 {
     if ($this->_table === null) {
         throw new Zym_Log_Exception('Database adapter instance has been removed by shutdown');
     }
     if (!$this->_columnMap) {
         $dataToInsert = $event;
     } else {
         $dataToInsert = array();
         foreach ($this->_columnMap as $columnName => $fieldKey) {
             $dataToInsert[$columnName] = $event[$fieldKey];
         }
     }
     $record = $this->_table->create($dataToInsert);
     $record->save();
 }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:22,代碼來源:Doctrine.php

示例5: get

 /**
  * get
  * returns a record for given key
  *
  * There are two special cases:
  *
  * 1. if null is given as a key a new record is created and attached
  * at the end of the collection
  *
  * 2. if given key does not exist, then a new record is create and attached
  * to the given key
  *
  * Collection also maps referential information to newly created records
  *
  * @param mixed $key                    the key of the element
  * @return Doctrine_Record              return a specified record
  */
 public function get($key)
 {
     if ($key === null || !isset($this->data[$key])) {
         $record = $this->_table->create();
         if (isset($this->referenceField)) {
             $value = $this->reference->get($this->relation->getLocal());
             if ($value !== null) {
                 $record->set($this->referenceField, $value, false);
             } else {
                 $record->set($this->referenceField, $this->reference, false);
             }
         }
         $this->data[] = $record;
         return $record;
     }
     return $this->data[$key];
 }
開發者ID:snouhaud,項目名稱:camptocamp.org,代碼行數:34,代碼來源:Collection.php

示例6: create

 /**
  *
  * @param Doctrine_Table $table
  * @param array $data
  */
 public function create(Doctrine_Table $table, $data)
 {
     foreach ($data as $row) {
         $table->create($row)->save();
     }
 }
開發者ID:robo47,項目名稱:robo47-components,代碼行數:11,代碼來源:AbstractTest.php


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