本文整理汇总了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;
}