本文整理汇总了PHP中Item::select方法的典型用法代码示例。如果您正苦于以下问题:PHP Item::select方法的具体用法?PHP Item::select怎么用?PHP Item::select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::select方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a listing of the resource.
* e.g. curl -i --user a@aa.com:a1\! localhost:8000/api/v1/item\?user_id=1
*
* @return Response
*/
public function index()
{
$validator = Validator::make(Input::all(), array('user_id' => 'numeric|required_with:first,last', 'name' => 'min:3', 'last' => 'numeric', 'first' => 'numeric'));
if ($validator->fails()) {
return Response::json(array('errors' => $validator->messages()), 400);
}
$userId = Input::get('user_id');
$itemName = Input::get('name');
$first = Input::get('first');
$last = Input::get('last');
if ($first && $last) {
// Return an error if the user specified both a first and a last parameter
return Response::json(array('errors' => "Cannot have both first and last parameters"), 400);
}
$query = Item::select('*');
if (is_numeric($userId)) {
$query = $query->creator($userId);
if (is_numeric($first)) {
$query->orderBy('created_date', 'asc');
$query->take($first);
} else {
if (is_numeric($last)) {
$query->orderBy('created_date', 'desc');
$query->take($last);
}
}
}
if (is_string($itemName)) {
$query = $query->nameLike($itemName);
}
// TODO Pagination e.g. Item::Take(50)->skip(50)-get();
$items = $query->get();
return Response::json(array('items' => $items->toArray()), 200);
}
示例2: getQueryItem
/**
* getQueryItem
*/
public function getQueryItem()
{
$code = Input::get('code');
$items = Item::select(array('id', 'code'))->where('code', 'LIKE', '%' . $code . '%')->get();
/*$data = array();
foreach ( $items as $item ):
$data[] = $item->code;
endforeach;*/
return Response::json($items->toArray());
}
示例3: lang
</div>
<form name='addItem' action='<?php
echo $_SERVER['PHP_SELF'];
?>
' method='post'>
<input type='hidden' name='form' value='addItem' />
<p>
<label><?php
echo lang("TYPE");
?>
</label>
<?php
echo Item::select();
?>
</p>
<p>
<label><?php
echo lang("NAME");
?>
</label>
<input type='text' class="form-control" name='name' />
</p>
<p>
<label><?php
echo lang("PRICE");
?>
示例4: getItemListsBySearch
/**
* Get item lists by search for rendering result list.
*
* @return void
*/
public function getItemListsBySearch($conditions, $display_way, $perPage, $orderType, $order)
{
global $data;
global $settings;
$columns = array('*', DB::raw("items.id as id"), 'items.title_' . $data['language'] . ' as title', 'items.content_' . $data['language'] . ' as content', 'sub_categories.' . $data['language'] . ' as sub_category', 'categories.code as category_code', 'stations.' . $data['language'] . ' as station', 'areas.' . $data['language'] . ' as area', 'items.informations as informations', DB::raw("GROUP_CONCAT(photos.path SEPARATOR ',') as photos"), DB::raw("AVG(reviews.rate) as review_average"));
if (isset($conditions['details'])) {
foreach ($conditions['details'] as $key => $detail) {
if ($data['item_informations'][$display_way][$key]['settings']['search_type'] == 'range') {
$columns[] = DB::raw("CAST(common_schema.extract_json_value(items.informations, '/" . $key . "') AS UNSIGNED) as " . $key);
} else {
$columns[] = DB::raw("common_schema.extract_json_value(items.informations, '/" . $key . "') as " . $key);
}
}
}
if ($orderType != 'recent') {
if ($orderType == 'price') {
$columns[] = DB::raw("CAST(common_schema.extract_json_value(items.informations, '/" . $orderType . "') AS UNSIGNED) as " . $orderType);
} else {
$columns[] = DB::raw("common_schema.extract_json_value(items.informations, '/" . $orderType . "') as " . $orderType);
}
}
$stmt = Item::select($columns)->leftJoin('customers', 'items.customer_id', '=', 'customers.id')->leftJoin('sub_categories', 'items.sub_category_id', '=', 'sub_categories.id')->leftJoin('categories', 'sub_categories.category_id', '=', 'categories.id')->leftJoin('stations', 'customers.station_id', '=', 'stations.id')->leftJoin('areas', 'customers.area_id', '=', 'areas.id')->leftJoin('photos', 'items.id', '=', 'photos.item_id')->leftJoin('reviews', 'items.id', '=', 'reviews.item_id')->where('customers.city_id', '=', $data['area']['id'])->where('categories.code', '=', $display_way);
if ($conditions['search_by'] == 'station' && isset($conditions['station'])) {
if ($conditions['station'] != '') {
$stmt->whereIn('stations.code', $conditions['station']);
}
} elseif ($conditions['search_by'] == 'area' && isset($conditions['area'])) {
if ($conditions['area'] != '') {
$stmt->whereIn('areas.code', $conditions['area']);
}
}
if (isset($conditions['sub_category'])) {
$stmt->where('sub_categories.code', '=', $conditions['sub_category']);
}
if (isset($conditions['freeword'])) {
$freewords = explode(' ', str_replace(' ', ' ', $conditions['freeword']));
foreach ($freewords as $key => $freeword) {
$stmt->where(function ($query) use($data, $freeword) {
$query->where('items.title_' . $data['language'], 'like', '%' . $freeword . '%');
$query->orWhere('items.content_' . $data['language'], 'like', '%' . $freeword . '%');
$query->orWhere('stations.' . $data['language'], 'like', '%' . $freeword . '%');
$query->orWhere('areas.' . $data['language'], 'like', '%' . $freeword . '%');
$query->orWhere('sub_categories.' . $data['language'], 'like', '%' . $freeword . '%');
});
}
}
if (isset($conditions['details'])) {
foreach ($conditions['details'] as $key => $detail) {
// Range
if ($data['item_informations'][$display_way][$key]['settings']['search_type'] == 'range') {
$stmt->whereBetween(DB::raw("CAST(common_schema.extract_json_value(items.informations, '/" . $key . "') AS UNSIGNED)"), array($detail['min'], $detail['max']));
}
// Boolean
if ($data['item_informations'][$display_way][$key]['settings']['search_type'] == 'boolean') {
$stmt->where(DB::raw("common_schema.extract_json_value(items.informations, '/" . $key . "')"), '=', $detail);
}
}
}
$stmt->groupBy('items.id')->orderBy('customers.validity_flag', 'DESC');
if ($orderType == 'recent') {
$stmt->orderBy('items.created_at', 'DESC');
} elseif ($orderType == 'rating') {
$stmt->orderBy('review_average', 'DESC');
} else {
$stmt->orderBy($orderType, $order);
}
//print($stmt->toSql());
//exit;
$result = $stmt->paginate($perPage)->toArray();
$result['range'] = $this->makePaginationLinks($result);
foreach ($result['data'] as $key => $row) {
$result['data'][$key]['reviews'] = array();
foreach ($data['review_items'][$display_way] as $reviewItem) {
$result['data'][$key]['reviews'][$reviewItem['code']] = array();
$result['data'][$key]['reviews'][$reviewItem['code']] = $this->getReviews($row['id'], $reviewItem['id']);
}
$result['data'][$key]['informations'] = json_decode($result['data'][$key]['informations'], true);
}
return $result;
}
示例5: show_form
function show_form($errors = '')
{
if ($errors) {
$error_text .= '<p class="error">';
$error_text .= implode('</p><p class="error">', $errors);
$error_text .= '</p>';
} else {
$error_text = '';
}
echo $error_text;
$item = new Item(MT_TABLE);
if ($_GET['id']) {
$row = $item->row($_GET['id']);
}
//print the html form
?>
<div class="table">
<img src="img/bg-th-left.gif" width="8" height="7" alt="" class="left" />
<img src="img/bg-th-right.gif" width="7" height="7" alt="" class="right" />
<form method="POST" action="sub_item.php">
<table class="listing" cellpadding="0" cellspacing="0" id="tabella">
<thead>
<tr>
<th class="first" width="177">Name</th>
<th class="last">Field</th>
</tr>
</thead>
<tbody>
<tr>
<td class="first">Label</td>
<td class="last"><input type="text" name="label" value="<?php
echo $row['label'];
?>
"></td>
</tr>
<tr>
<td class="first">Link</td>
<td class="last"><input type="text" name="link" value="<?php
echo $row['link_url'];
?>
"></td>
</tr>
<tr>
<td class="first">Parent</td>
<td class="last">
<select id="parent_id" name="parent_id"><option value="">Choose one..</option>
<?php
$item->select($_GET['parent_id']);
?>
</select>
</td>
</tr>
</tbody>
</table>
<input type="hidden" name="_check" value="1"/>
<input type="hidden" name="_id" value="<?php
echo $_GET['id'];
?>
"/>
<input type="submit" value="Go">
</form>
<?php
}
示例6: getItemByCategory
/**
* Get Item list by food_category ID.
*
* @param int $id_category
* @return array result
*/
public function getItemByCategory($id_category)
{
$items = Item::select(array('food_items.*', 'food_category.name'))->leftJoin('food_category', 'food_items.food_category_id', '=', 'food_category.id')->get();
return $items;
}