本文整理匯總了PHP中Doctrine_Record::toArray方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Record::toArray方法的具體用法?PHP Doctrine_Record::toArray怎麽用?PHP Doctrine_Record::toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine_Record
的用法示例。
在下文中一共展示了Doctrine_Record::toArray方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _form
protected function _form(Doctrine_Record $entity)
{
$form = $this->_getForm();
if ($entity->exists()) {
$form->setDefaults($entity->toArray());
}
if ($this->getRequest()->getParam('cancel')) {
$this->_redirectToIndex();
}
if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getParams())) {
$messageKey = 'entityAdded';
if ($entity->exists()) {
$messageKey = 'entityUpdated';
}
$this->_saveEntity($entity, $form);
$this->_helper->messenger->success($this->_messages[$messageKey]);
$this->_redirectToIndex();
}
$this->view->form = $form;
}
示例2: populateDummyRecord
/**
* populateDummyRecord
*
* @param Doctrine_Record $record
* @return Doctrine_Record $record
*/
public function populateDummyRecord(Doctrine_Record $record)
{
$lorem = explode(' ', "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem \n Ipsum has been the industry's standard dummy text ever since the 1500s, when an \n unknown printer took a galley of type and scrambled it to make a type specimen book. \n It has survived not only five centuries, but also the leap into electronic \n typesetting, remaining essentially unchanged. It was popularised in the 1960s with \n the release of Letraset sheets containing Lorem Ipsum passages, and more recently \n with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.");
$columns = array_keys($record->toArray());
$pks = $record->getTable()->getIdentifier();
if (!is_array($pks)) {
$pks = array($pks);
}
foreach ($columns as $column) {
if (!in_array($column, $pks)) {
if ($relation = $this->isRelation($record, $column)) {
$alias = $relation['alias'];
$relationObj = $record->{$alias};
$this->populateDummyRecord($relationObj);
} else {
$definition = $record->getTable()->getDefinitionOf($column);
switch ($definition['type']) {
case 'string':
shuffle($lorem);
$record->{$column} = substr(implode(' ', $lorem), 0, $definition['length']);
break;
case 'integer':
$record->{$column} = rand();
break;
case 'boolean':
$record->{$column} = true;
break;
case 'float':
$record->{$column} = number_format(rand($definition['length'], $definition['length']), 2, '.', null);
break;
case 'array':
$record->{$column} = array('test' => 'test');
break;
case 'object':
$record->{$column} = new stdObject();
break;
case 'blob':
$record->{$column} = '';
break;
case 'clob':
$record->{$column} = '';
break;
case 'timestamp':
$record->{$column} = date('Y-m-d h:i:s', time());
break;
case 'time':
$record->{$column} = date('h:i:s', time());
break;
case 'date':
$record->{$column} = date('Y-m-d', time());
break;
case 'enum':
$record->{$column} = 'test';
break;
case 'gzip':
$record->{$column} = 'test';
break;
}
}
}
}
return $record;
}
示例3: extractFormData
/**
* Make array from Doctrine object suitable for supplied form
*
* @param Doctrine_Record $model
* @param sfFormDoctrine $form
* @return array
*/
public function extractFormData(Doctrine_Record $model, sfFormDoctrine $form)
{
$fields = $form->getWidgetSchema()->getFields();
$props = $model->toArray();
return array_intersect_key($props, $fields);
}
示例4: format_radix
/**
* Format a Doctrine_Record as an array.
*
* @param Doctrine_Record $record
* @return array $radix
*/
protected function format_radix(Doctrine_Record $record)
{
return $record->toArray();
}
示例5: getObjectProperties
/**
* Returns object properties
*
* @param Doctrine_Record $object
*
* @return array
*/
public function getObjectProperties($object)
{
$array = $object->toArray();
$t = Doctrine::getTable(get_class($object));
unset($array[$t->getGeometryColumnName()], $array[$t->getIdentifier()], $array['bbox']);
return $array;
}