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