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


PHP Model::cloneResultMapHydrate方法代码示例

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


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

示例1: valid

 /**
  * Check whether internal resource has rows to fetch
  *
  * @return boolean
  */
 public function valid()
 {
     if ($this->_type === 1) {
         //The result is bigger than 32 rows so it's retrieved one by one
         if ($this->_result !== false) {
             $row = $this->_result->fetch($this->_result);
         } else {
             $row = false;
         }
     } else {
         //The full rows are dumped into $this->rows
         if (is_array($this->_rows) === true) {
             $row = current($this->_rows);
             if (is_object($row) === true) {
                 next($this->_rows);
             }
         } else {
             $row = false;
         }
     }
     //Valid records are arrays
     if (is_array($row) === true || is_object($row) === true) {
         //The result type=1 so we need to build every row
         if ($this->_type === 1) {
             //Each row in a complex result is a Phalcon\Mvc\Model\Row instance
             switch ((int) $this->_hydrateMode) {
                 case 0:
                     $activeRow = new Row();
                     break;
                 case 1:
                     $activeRow = array();
                     break;
                 case 2:
                     $activeRow = new stdClass();
                     break;
                     //@note no default exception
             }
             //Set records as dirty state PERSISTENT by default
             $dirtyState = 0;
             foreach ($this->_columnTypes as $alias => $column) {
                 if ($column['type'] === 'object') {
                     //Object columns are assigned column by column
                     $columnMap = $column['columnMap'];
                     $attributes = $column['attributes'];
                     $rowModel = array();
                     foreach ($column['attributes'] as $attribute) {
                         //Columns are supposed to be in the form _table_field
                         $rowModel[$attribute] = $row['_' . $column['column'] . '_' . $attribute];
                     }
                     //Generate the column value according to the hydration type
                     switch ((int) $this->_hydrateMode) {
                         case 0:
                             //Check if the resultset must keep snapshots
                             if (isset($column['keepSnapshots']) === true) {
                                 $keepSnapshots = $column['keepSnapshots'];
                             } else {
                                 $keepSnapshots = false;
                             }
                             //Get the base instance
                             $instance = $column['instance'];
                             //Assign the values to the attributes using a column map
                             $value = Model::cloneResultMap($instance, $rowModel, $columnMap, $dirtyState, $keepSnapshots);
                             break;
                         default:
                             //Other kinds of hydrations
                             $value = Model::cloneResultMapHydrate($rowModel, $columnMap, $this->_hydrateMode);
                             break;
                     }
                     //The complete object is assigned to an attribute with the name of the alias or
                     //the model name
                     $attribute = null;
                     if (isset($column['balias']) === true) {
                         $attribute = $column['balias'];
                     }
                 } else {
                     //Scalar columns are simply assigned to the result objects
                     if (isset($column['sqlAlias']) === true) {
                         $value = $row[$column['sqlAlias']];
                     } else {
                         if (isset($row[$alias]) === true) {
                             $value = $row[$alias];
                         }
                     }
                     //If a 'balias' is defined it is not an unnamed scalar
                     if (isset($column['balias']) === true) {
                         $attribute = $alias;
                     } else {
                         $attribute = str_replace('_', '', $alias);
                     }
                 }
                 if (isset($attribute) === false) {
                     $attribute = null;
                 }
                 //Assign the instance according to the hydration type
                 switch ((int) $this->_hydrateMode) {
//.........这里部分代码省略.........
开发者ID:aisuhua,项目名称:phalcon-php,代码行数:101,代码来源:Complex.php


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