本文整理汇总了PHP中Eloquent::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Eloquent::get方法的具体用法?PHP Eloquent::get怎么用?PHP Eloquent::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Eloquent
的用法示例。
在下文中一共展示了Eloquent::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: query
/**
* @param $className
* @param $parameters
* @param bool $runQuery
* @return array
*/
public function query($className, $parameters, $runQuery = true)
{
// set the default parameters
$defaultParameters = array('where' => null, 'limit' => null, 'skip' => null, 'order' => null, 'keys' => null, 'count' => null, 'include' => null);
$parameters = array_merge($defaultParameters, $parameters);
extract($parameters);
// specify the selected columns
$selected_columns = $this->select($keys);
// eager loading functionality
$this->with($include);
// filtering the data
// todo review this line
$query = $this->object instanceof Model ? $this->object->query() : $this->object;
$this->object = $this->where($query, $where);
// support pagination using limit and skip (offset)
$this->limit($limit, $skip);
// order the result
$this->order($order);
if ($runQuery) {
// prepare the json main structure
$jsonData = array('results' => array());
// run the query based on the above configuration
$jsonData['results'] = $this->object->get($selected_columns);
if (!is_null($count)) {
// add the count index if the user ask for
$jsonData['count'] = $this->object->count();
}
// return the parsed results and count if available
return $jsonData;
}
}
示例2: getList
function getList()
{
$this->getInitedList();
if (is_null($this->per_page)) {
return $this->model->get();
}
return $this->model->paginate($this->per_page);
}
示例3: getResult
/**
* Gets results from prepared query
*
* @return null
*/
private function getResult()
{
$this->result_object = $this->query->get();
if ($this->query_type == 'builder') {
$this->result_array = array_map(function ($object) {
return (array) $object;
}, $this->result_object);
} else {
$this->result_array = array_map(function ($object) {
return (array) $object;
}, $this->result_object->toArray());
}
}