本文整理汇总了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];
}
示例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();
}
示例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();
}
示例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();
}
示例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];
}
示例6: create
/**
*
* @param Doctrine_Table $table
* @param array $data
*/
public function create(Doctrine_Table $table, $data)
{
foreach ($data as $row) {
$table->create($row)->save();
}
}