本文整理汇总了PHP中App\Http\Controllers\DB::statement方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::statement方法的具体用法?PHP DB::statement怎么用?PHP DB::statement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\DB
的用法示例。
在下文中一共展示了DB::statement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updatePrices
/**
* Show the application dashboard.
*
* @return Response
*/
public function updatePrices()
{
//return view('admin.adminlanding');
\Excel::load("public\\data\\Prices.xlsx", function ($reader) {
$results = $reader->get();
date_default_timezone_set("Asia/Dubai");
$insertcount = 0;
foreach ($results as $result) {
//loop through all of the input item codes
$pricedata = [];
$pricedata['classid'] = $result->custgroup;
$pricedata['itemcode'] = $result->itemcode;
$pricedata['aedprice'] = $result->aedprice;
$pricedata['usdprice'] = $result->usdprice;
$pricedata['lastaedprice'] = 0;
$pricedata['lastusdprice'] = 0;
$pricedata['ispromo'] = $result->ispromo;
$pricedata['promodisc'] = $result->promodisc;
$pricedata['updatedby'] = \Auth::user()->id;
$pricedata['isactive'] = 1;
if (\DB::statement("UPDATE itemprices SET isactive = 0 WHERE itemcode = '" . $result->itemcode . "' AND classid = " . $result->custgroup)) {
\DB::table('itemprices')->insert($pricedata);
$insertcount = $insertcount + 1;
}
}
echo $insertcount . " items updated!";
});
}
示例2: item_data
public function item_data()
{
\DB::statement(\DB::raw('set @rownum=0'));
$items = Item::select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'id', 'name']);
return Datatables::of($items)->addColumn('action', function ($item) {
return '<a href="./item/edit/' . $item->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
})->make(true);
}
示例3: customer_data
public function customer_data()
{
\DB::statement(\DB::raw('set @rownum=0'));
$customers = Customer::select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'id', 'name', 'address', 'phone', 'membership']);
return Datatables::of($customers)->addColumn('action', function ($customer) {
return '<a href="./customer/edit/' . $customer->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
})->make(true);
}
示例4: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
$nombre = $request->nombre;
if (trim($nombre) != "") {
\DB::statement('CALL add_tipo_galeria("' . $nombre . '")');
}
//
}
示例5: asset_category_data
public function asset_category_data()
{
\DB::statement(\DB::raw('set @rownum=0'));
$asset_categories = \DB::table('asset_categories')->join('asset_types', 'asset_types.id', '=', 'asset_categories.asset_type_id')->select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'asset_categories.id as ac_id', 'asset_categories.name as ac_name', 'asset_categories.code as ac_code', \DB::raw("CONCAT(asset_types.code,'-',asset_types.name) as at_b")]);
return Datatables::of($asset_categories)->addColumn('action', function ($asset_category) {
return '<a href="./asset_category/edit/' . $asset_category->ac_id . '" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-edit"></i> Edit</a>
';
})->make(true);
}
示例6: asset_type_data
public function asset_type_data()
{
\DB::statement(\DB::raw('set @rownum=0'));
$asset_types = AssetType::select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'id', 'code', 'name']);
return Datatables::of($asset_types)->addColumn('action', function ($asset_type) {
return '
<a href="./asset_type/edit/' . $asset_type->id . '" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-edit"></i> Edit</a>
';
})->make(true);
}
示例7: user_data
public function user_data()
{
\DB::statement(\DB::raw('set @rownum=0'));
$users = User::select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'id', 'employee_name', 'nip', 'address']);
return Datatables::of($users)->addColumn('action', function ($user) {
return '<a href="./user/edit/' . $user->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>
<button id="btn-delete" class="btn btn-xs btn-danger" data-remote="./user/destroy/' . $user->id . '">Delete</button>
';
})->make(true);
}
示例8: remove
public function remove()
{
$itemid = Input::get('itemid');
$userid = \Auth::user()->id;
$delqry = "DELETE FROM currentcart WHERE itemcode IN (SELECT itemcode FROM itemmas WHERE id = " . $itemid . ") AND userid = " . $userid;
if (\DB::statement($delqry)) {
echo 1;
} else {
echo 0;
}
}
示例9: ma_asset_items
public function ma_asset_items()
{
\DB::statement(\DB::raw('set @rownum=0'));
$datas = TransactionItem::select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'id', 'index', 'name'])->where('user_id', '=', Auth::user()->id);
return Datatables::of($datas)->addColumn('action', function ($data) {
return '
<a href="#" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-edit"></i> Edit</a>
<a href="#" class="btn btn-xs btn-default"><i class="glyphicon glyphicon-edit"></i> View</a>
';
})->make(true);
}
示例10: store
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
// dd($request->file());
// dd($request->input());
if ($request->hasFile('url')) {
$archivo = $request->file('url');
$ext = $archivo->getClientOriginalExtension();
if (mb_strtolower($ext) == "jpg" || mb_strtolower($ext) == "png" || mb_strtolower($ext) == "jpeg") {
$nombre = "";
$str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
for ($i = 0; $i < 16; $i++) {
$nombre .= substr($str, rand(0, strlen($str)), 1);
}
$nombrem = $nombre . "_movil";
$nombre .= "." . $ext;
$folder = str_replace(" ", "_", '/assets/publicidad/' . date('M') . '/');
if (!file_exists(getcwd() . $folder)) {
mkdir(getcwd() . $folder, 0777, true);
}
if ($archivo->move(getcwd() . $folder, $nombre)) {
if ($request->hasFile('url_movil')) {
$archivom = $request->file('url_movil');
$extm = $archivom->getClientOriginalExtension();
if (mb_strtolower($extm) == "jpg" || mb_strtolower($extm) == "png" || mb_strtolower($extm) == "jpeg") {
$nombrem .= "." . $extm;
if (!$archivom->move(getcwd() . $folder, $nombrem)) {
echo "La versión movil no se suvió";
}
}
}
$cliente = $request->nombre;
$posicion = $request->posicion;
$seccion = $request->categoria;
$url = $folder . $nombre;
$link = $request->link;
if (trim($cliente) != "" && trim($url) != "" && trim($link) != "") {
if (\DB::statement('CALL add_publicidad("' . $cliente . '",' . $posicion . ',' . $seccion . ',"' . $url . '","' . $link . '");')) {
echo "Guardada";
} else {
echo "Por elmomento no fue posible guardar la imagen, intentelo de nuevo.";
}
} else {
echo "Falta información";
}
} else {
echo "No pudo ser almacenada laimagen";
}
} else {
echo "Extensión de archivo incorrecta";
}
}
// insert into publicidad (cliente, fecha_inicio, posicion, seccion, url, link, activo) values (ncliente, now(), nposicion, nseccion, nurl, nlink, 1);
}
示例11: package_data
public function package_data()
{
\DB::statement(\DB::raw('set @rownum=0'));
$packages = Package::select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'id', 'name', 'price_regular', 'price_express', 'unit', 'description']);
return Datatables::of($packages)->editColumn('price_regular', function ($package) {
return number_format($package->price_regular, 2, ',', '.');
})->editColumn('price_express', function ($package) {
return number_format($package->price_express, 2, ',', '.');
})->addColumn('action', function ($package) {
return '<a href="./package/edit/' . $package->id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a>';
})->make(true);
}
示例12: get_kpc_data
public function get_kpc_data()
{
\DB::statement(\DB::raw('set @rownum=0'));
$kpcs = RegionKPC::select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'id', 'region_kprk_id', 'code', 'name', 'abbreviation', 'date_open']);
return Datatables::of($kpcs)->addColumn('action', function ($kpc) {
return '
<a href="./edit/' . $kpc->region_kprk_id . '/' . $kpc->id . '" class="btn btn-xs btn-warning"><i class="glyphicon glyphicon-edit"></i> Edit</a>
<button id="btn-delete" class="btn btn-xs btn-danger" data-remote="./destroy_kpc/' . $kpc->id . '">Delete</button>
';
})->editColumn('date_open', function ($kpc) {
return $kpc->date_open ? with(new Carbon($kpc->date_open))->format('d/m/Y') : '';
})->make(true);
}
示例13: transaction_data
public function transaction_data()
{
\DB::statement(\DB::raw('set @rownum=0'));
$transactions = \DB::table('transactions')->join('customers', 'transactions.customer_id', '=', 'customers.id')->join('status', 'transactions.status_id', '=', 'status.id')->select([\DB::raw('@rownum := @rownum + 1 AS rownum'), 'status.name as status_name', 'status.id as status_id', 'transactions.id as trans_id', 'transactions.invoice_number as invoice_number', 'transactions.date_order as date_order', 'transactions.date_deliver as date_deliver', 'transactions.time_deliver as time_deliver', 'transactions.rack_info', 'customers.name as cust_name', 'customers.phone as cust_phone'])->orderBy('transactions.date_deliver', 'desc');
return Datatables::of($transactions)->editColumn('cust_name', function ($transaction) {
return $transaction->cust_name . '-' . $transaction->cust_phone;
})->editColumn('status_name', function ($transaction) {
return $transaction->status_name . '/' . $transaction->rack_info;
})->editColumn('date_order', function ($transaction) {
return $transaction->date_order ? with(new Carbon($transaction->date_order))->format('d/m/Y') : '';
})->editColumn('date_deliver', function ($transaction) {
return $transaction->date_deliver ? with(new Carbon($transaction->date_deliver))->format('d/m/Y') . '-' . $transaction->time_deliver : '';
})->addColumn('action', function ($transaction) {
return '<a href="./transaction/edit/' . $transaction->trans_id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-edit"></i> Edit</a> <a href="./transaction/detail/' . $transaction->trans_id . '" class="btn btn-xs btn-primary"><i class="glyphicon glyphicon-globe"></i> Detail</a>';
})->make(true);
}
示例14: update
/**
* Update the specified resource in storage.
*
* @param $id
* @param QuestionRequest $request
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
public function update($id, QuestionRequest $request)
{
\DB::statement("SET SESSION time_zone = '+00:00'");
$options = [$request->option_A, $request->option_B, $request->option_C, $request->option_D];
if (count(array_unique($options)) == 4) {
$question = Question::findOrFail($id);
$previous_questions = Auth::user()->questions->pluck('question')->toArray();
if (($key = array_search($question->question, $previous_questions)) !== false) {
unset($previous_questions[$key]);
}
if (!in_array($request->question, $previous_questions)) {
$question->update($request->all());
return redirect('quiz/design')->with(['heading' => 'SUCCESS', 'message' => 'You have successfully updated the question']);
} else {
return redirect('quiz/design')->with(['heading' => 'ERROR', 'message' => 'You have already submitted this question before']);
}
} else {
return redirect('quiz/design/' . $id . '/edit')->withInput()->with(['heading' => 'ERROR', 'message' => 'All four options must be different']);
}
}
示例15: getGathering
public function getGathering($my_class = '', $supported_classes = '', $min_level = 0, $max_level = 0)
{
$supported_classes = explode(',', $supported_classes);
$show_quests = in_array($my_class, $supported_classes);
if (empty($supported_classes)) {
exit('No supported class selected... Todo: real error');
}
// TODO
$all_classes = ClassJob::get_id_abbr_list();
foreach ($supported_classes as $k => $v) {
if (in_array($v, array_keys($all_classes))) {
$supported_classes[$k] = $all_classes[$v];
} else {
unset($supported_classes[$k]);
}
}
if (empty($supported_classes)) {
exit('No supported class recognized...');
}
// TODO
$jobs = ClassJob::with('name')->whereIn('id', $supported_classes)->get();
foreach ($jobs as $k => $v) {
$jobs[$k] = $v->name->term;
}
if ($my_class != 'BTL') {
$job = ClassJob::get_by_abbr($my_class);
} else {
$job = $my_class;
}
if (empty($job)) {
exit('No primary class recognized...');
}
// TODO
$top_query = $inner_query = $join = $where = $union = $having = '';
$parameters = [];
\DB::statement('SET SESSION group_concat_max_len=16384');
if (in_array($my_class, array('MIN', 'BTN'))) {
// Add Nodes
$top_query .= "\n\t\t\t\t\t(\n\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\tCOUNT(*)\n\t\t\t\t\t\tFROM `cluster_items` AS `ci`\n\t\t\t\t\t\tJOIN `clusters` AS `c` ON `c`.`id` = `ci`.`cluster_id`\n\t\t\t\t\t\tWHERE `c`.`classjob_id` = ? AND `ci`.`item_id` = `x`.`item_id`\n\t\t\t\t\t) AS nodes,\n\t\t\t";
$parameters[] = $job->id;
$having = "HAVING nodes > 0";
} else {
// Battling or Fishing
$join = "LEFT JOIN `cluster_items` AS `ci` ON `ci`.`item_id` = `i`.`id` " . 'LEFT JOIN `item_ui_category` AS `iuc` ON `iuc`.`id` = `i`.`itemuicategory_id` ' . 'LEFT JOIN `translations` AS `iuct` ON `iuct`.`id` = `iuc`.`name_en`';
// FSH where the item is "seafood"
// BTL where the item is not "seafood"
$where = "AND `iuct`.`term` " . ($my_class == 'BTL' ? '!' : '') . "= 'Seafood'";
$where .= " AND `ci`.`id` IS NULL";
}
$parameters[] = $min_level;
$parameters[] = $max_level;
$parameters = array_merge($parameters, $supported_classes);
if ($my_class != 'BTL') {
$union = "\n\t\t\t\t\tUNION\n\n\t\t\t\t\tSELECT\n\t\t\t\t\t\t`i`.`id`, t.term AS name, `i`.level, `i`.`min_price`, qi.amount AS amount, \n\t\t\t\t\t\tqi.level AS quest_level, qi.quality AS quest_quality\n\t\t\t\t\tFROM quest_items AS qi\n\t\t\t\t\tJOIN items AS i ON i.id = qi.item_id\n\t\t\t\t\tJOIN classjob AS j ON j.id = qi.classjob_id\n\t\t\t\t\tJOIN translations AS t ON t.id = i.name_" . Config::get('language') . "\n\t\t\t\t\tWHERE j.id = ?\n\t\t\t\t\t\tAND qi.level BETWEEN ? AND ?\n\t\t\t";
$parameters[] = $job->id;
$parameters[] = $min_level;
$parameters[] = $max_level;
}
// TODO Caching
$items = \DB::select("\n\t\t\tSELECT x.*,\n\t\t\t\t" . $top_query . "\n\t\t\t\t(\n\t\t\t\t\tSELECT COUNT(*)\n\t\t\t\t\tFROM `items_npcs_shops` AS `ins`\n\t\t\t\t\tWHERE `ins`.`item_id` = `x`.`item_id`\n\t\t\t\t) AS vendors, \n\t\t\t\t(\n\t\t\t\t\tSELECT COUNT(*)\n\t\t\t\t\tFROM `npcs_items` AS `ni`\n\t\t\t\t\tWHERE `ni`.`item_id` = `x`.`item_id`\n\t\t\t\t) AS beasts\n\t\t\tFROM (\n\t\t\t\tSELECT \n\t\t\t\t\t`i`.`id` AS `item_id`, t.term AS name, `i`.level, `i`.`min_price`, SUM(cj.amount) AS amount,\n\t\t\t\t\tNULL AS quest_level, NULL AS quest_quality\n\t\t\t\tFROM `careers` AS `c`\n\t\t\t\tJOIN `items` AS `i` ON `i`.`id` = `c`.`identifier`\n\t\t\t\tJOIN `career_classjob` AS `cj` ON `cj`.`career_id` = `c`.`id`\n\t\t\t\tJOIN translations AS t ON t.id = i.name_" . Config::get('language') . "\n\t\t\t\t" . $join . "\n\t\t\t\tWHERE\n\t\t\t\t\t`c`.`type` = 'item'\n\t\t\t\t\tAND `c`.`level` BETWEEN ? AND ?\n\t\t\t\t\tAND `cj`.`classjob_id` in (" . str_pad('', count($supported_classes) * 2 - 1, '?,') . ")\n\t\t\t\t\t" . $where . "\n\t\t\t\tGROUP BY `c`.`identifier`\n\n\t\t\t\t" . $union . "\n\t\t\t\t\n\t\t\t\tORDER BY `item_id` ASC\n\t\t\t) AS x\n\t\t\t" . $having, $parameters);
if ($my_class != 'BTL') {
$quest_items = [];
// Rip out Quest Entries
foreach ($items as $k => $result) {
if ($result->quest_level != NULL) {
$quest_items[] = $result;
unset($items[$k]);
}
}
// Put them back in, either merge or insert
if ($show_quests) {
foreach ($quest_items as $quest_item) {
foreach ($items as $k => $result) {
if ($quest_item->item_id == $result->item_id) {
// Merge
$original_amount = $result->amount;
$quest_amount = $quest_item->amount;
$items[$k] = $quest_item;
$items[$k]->amount = $original_amount;
$items[$k]->quest_amount = $quest_amount;
continue 2;
}
}
// If a match was found it would have continued
// This means at this point we add it in straight up
$quest_item->quest_amount = $quest_item->amount;
$items[] = $quest_item;
}
}
// Fishing doesn't have an ilvl...
if ($my_class != 'FSH') {
$sortable_items = [];
foreach ($items as $row) {
$sortable_items[$row->level][] = $row;
}
ksort($sortable_items);
$items = [];
foreach ($sortable_items as $rows) {
foreach ($rows as $row) {
$items[] = $row;
//.........这里部分代码省略.........