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


PHP Doctrine_Record::toArray方法代碼示例

本文整理匯總了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;
 }
開發者ID:prosalov,項目名稱:zf1-code-example,代碼行數:20,代碼來源:Crud.php

示例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;
 }
開發者ID:walterfrs,項目名稱:mladek,代碼行數:69,代碼來源:Import.php

示例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);
 }
開發者ID:EasyFinance,項目名稱:sfPhpunitPlugin,代碼行數:13,代碼來源:sfPHPUnitObjectHelper.php

示例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();
 }
開發者ID:kaakshay,項目名稱:audience-insight-repository,代碼行數:10,代碼來源:DOCframe_Resource.php

示例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;
 }
開發者ID:juacas,項目名稱:moodle-mod_treasurehunt,代碼行數:14,代碼來源:GeoJSON_Adapter_Doctrine.class.php


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