当前位置: 首页>>代码示例>>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;未经允许,请勿转载。