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


PHP FArrayHelper::firstKey方法代码示例

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


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

示例1: getRow

 /**
  * Get a row of data from the table
  *
  * @param   int   $id        Id
  * @param   bool  $format    The data
  * @param   bool  $loadJoin  Load the rows joined data @since 2.0.5 (used in J Content plugin)
  *
  * @return  object	Row
  */
 public function getRow($id, $format = false, $loadJoin = false)
 {
     if (is_null($this->rows)) {
         $this->rows = array();
     }
     $sig = $id . '.' . $format . '.' . $loadJoin;
     if (array_key_exists($sig, $this->rows)) {
         return $this->rows[$sig];
     }
     $fabrikDb = $this->getDb();
     $formModel = $this->getFormModel();
     $formModel->reset();
     $this->reset();
     $formModel->rowId = $id;
     $sql = $formModel->buildQuery();
     $fabrikDb->setQuery($sql);
     if (!$loadJoin) {
         if ($format == true) {
             $row = $fabrikDb->loadObject();
             $row = array($row);
             $this->formatData($row);
             /* $$$ hugh - if table is grouped, formatData will have turned $row into an
              * assoc array, so can't assume 0 is first key.
              * $this->rows[$sig] = $row[0][0];
              */
             $row = FArrayHelper::getValue($row, FArrayHelper::firstKey($row), array());
             $this->rows[$sig] = FArrayHelper::getValue($row, 0, new stdClass());
         } else {
             $this->rows[$sig] = $fabrikDb->loadObject();
         }
     } else {
         $rows = $fabrikDb->loadObjectList();
         $formModel->setJoinData($rows);
         if ($format == true) {
             $rows = array(ArrayHelper::toObject($rows));
             $this->formatData($rows);
             $rows = $rows[0];
             /* $$$ hugh - if list is grouped, formatData will have re-index as assoc array,
             			 /* so can't assume 0 is first key.
             			*/
             $this->rows[$sig] = FArrayHelper::getValue($rows, FArrayHelper::firstKey($rows), array());
         } else {
             // Content plugin - rows is 1 dimensional array
             $this->rows[$sig] = $rows;
         }
     }
     if (is_array($this->rows[$sig])) {
         $this->rows[$sig] = ArrayHelper::toObject($this->rows[$sig]);
     }
     return $this->rows[$sig];
 }
开发者ID:pascal26,项目名称:fabrik,代码行数:60,代码来源:list.php

示例2: getRow

 /**
  * Get a row of data from the table
  *
  * @param   int   $id        id
  * @param   bool  $format    the data
  * @param   bool  $loadJoin  load the rows joined data @since 2.0.5 (used in J Content plugin)
  *
  * @return  object	row
  */
 public function getRow($id, $format = false, $loadJoin = false)
 {
     if (is_null($this->rows)) {
         $this->rows = array();
     }
     $sig = $id . '.' . $format . '.' . $loadJoin;
     if (array_key_exists($sig, $this->rows)) {
         return $this->rows[$sig];
     }
     $fabrikDb = $this->getDb();
     $formModel = $this->getFormModel();
     $formModel->_rowId = $id;
     unset($formModel->query);
     $sql = $formModel->_buildQuery();
     $fabrikDb->setQuery($sql);
     if (!$loadJoin) {
         if ($format == true) {
             $row = $fabrikDb->loadObject();
             $row = array($row);
             $this->formatData($row);
             /* $$$ hugh - if table is grouped, formatData will have turned $row into an
              * assoc array, so can't assume 0 is first key.
              * $this->rows[$sig] = $row[0][0];
              */
             $row = JArrayHelper::getValue($row, FArrayHelper::firstKey($row), array());
             $this->rows[$sig] = JArrayHelper::getValue($row, 0, new stdClass());
         } else {
             $this->rows[$sig] = $fabrikDb->loadObject();
         }
         if ($fabrikDb->getErrorNum()) {
             JError::raiseError(500, $fabrikDb->getErrorMsg());
         }
     } else {
         $rows = $fabrikDb->loadObjectList();
         if ($fabrikDb->getErrorNum()) {
             JError::raiseError(500, $fabrikDb->getErrorMsg());
         }
         $formModel->setJoinData($rows);
         if ($format == true) {
             $this->formatData($rows);
             /* $$$ hugh - if list is grouped, formatData will have re-index as assoc array,
             			/* so can't assume 0 is first key.
             			 */
             $this->rows[$sig] = JArrayHelper::getValue($rows, FArrayHelper::firstKey($rows), array());
         } else {
             $this->rows[$sig] = JArrayHelper::getValue($rows, 0, array());
         }
     }
     return $this->rows[$sig];
 }
开发者ID:rogeriocc,项目名称:fabrik,代码行数:59,代码来源:list.php


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