当前位置: 首页>>代码示例>>PHP>>正文


PHP DataMapper::_run_get_rules方法代码示例

本文整理汇总了PHP中DataMapper::_run_get_rules方法的典型用法代码示例。如果您正苦于以下问题:PHP DataMapper::_run_get_rules方法的具体用法?PHP DataMapper::_run_get_rules怎么用?PHP DataMapper::_run_get_rules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataMapper的用法示例。


在下文中一共展示了DataMapper::_run_get_rules方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _to_object

 /**
  * To Object
  * Copies the values from a query result row to an object.
  * Also initializes that object by running get rules, and
  *   refreshing stored values on the object.
  *
  * Finally, if any "instantiations" are requested, those related objects
  *   are created off of query results
  *
  * This is only public so that the iterator can access it.
  *
  * @ignore
  * @param	DataMapper $item Item to configure
  * @param	object $row Query results
  */
 public function _to_object($item, $row)
 {
     // Populate this object with values from first record
     foreach ($row as $key => $value) {
         $item->{$key} = $value;
     }
     foreach ($this->fields as $field) {
         if (!isset($row->{$field})) {
             $item->{$field} = NULL;
         }
     }
     // Force IDs to integers
     foreach ($this->_field_tracking['intval'] as $field) {
         if (isset($item->{$field})) {
             $item->{$field} = intval($item->{$field});
         }
     }
     if (!empty($this->_field_tracking['get_rules'])) {
         $item->_run_get_rules();
     }
     $item->_refresh_stored_values();
     if ($this->_instantiations) {
         foreach ($this->_instantiations as $related_field => $field_map) {
             // convert fields to a 'row' object
             $row = new stdClass();
             foreach ($field_map as $item_field => $c_field) {
                 $row->{$c_field} = $item->{$item_field};
             }
             // get the related item
             $c =& $item->_get_without_auto_populating($related_field);
             // set the values
             $c->_to_object($c, $row);
             // also set up the ->all array
             $c->all = array();
             $c->all[0] = $c->get_clone();
         }
     }
 }
开发者ID:RVRKC,项目名称:Hackathon_2015,代码行数:53,代码来源:datamapper.php


注:本文中的DataMapper::_run_get_rules方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。