本文整理汇总了PHP中DB::getPdo方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getPdo方法的具体用法?PHP DB::getPdo怎么用?PHP DB::getPdo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB::getPdo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$input = Input::all();
$validation = Validator::make($input, Variant::$rules);
if ($validation->passes()) {
$this->variant->create($input);
$vid = DB::getPdo()->lastInsertId();
$templates = Template::getImages();
return Redirect::route('variants.assigntemp', compact('vid', 'templates'));
}
return Redirect::route('variants.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
}
示例2: addAction
public function addAction()
{
try {
$school = Input::get('hiddenSchools');
$name = Input::get('name');
$description = Input::get('description');
$publish = Input::get('publish');
$class = new Classes();
$class->name = $name;
$class->description = $description;
$class->published = $publish;
$class->save();
$id = DB::getPdo()->lastInsertId();
$schools = explode(',', $school);
for ($i = 0; $i < count($schools); $i++) {
if ($schools[$i] != "") {
$schoolclass = new Schoolclass();
$schoolclass->school = $schools[$i];
$schoolclass->class = $id;
$schoolclass->save();
}
}
//Session::put('id', $id);
Session::flash('status_success', 'Successfully Updated.');
return Redirect::route('admin/classEdit', array('id' => $id));
//return Redirect::route('admin/classEdit');
} catch (Exception $ex) {
echo $ex;
Session::flash('status_error', '');
}
}
开发者ID:AxelPardemann,项目名称:E-Learning-System-based-on-Laravel-and-Bootstrap,代码行数:31,代码来源:ClassController.php
示例3: up
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
$date = new Carbon();
DB::table('admin_controllers')->insert(array(array('controller' => 'search', 'role_name' => 'Search log', 'role_order' => 4, 'role_section' => 3, 'created_at' => $date, 'updated_at' => $date)));
$controller_id = DB::getPdo()->lastInsertId();
DB::table('admin_actions')->insert(array(array('controller_id' => $controller_id, 'action' => 'index', 'inherit' => -1, 'edit_based' => 0, 'name' => 'View Search Log', 'about' => null, 'created_at' => $date, 'updated_at' => $date)));
}
示例4: up
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
// create package table
Schema::create('tests', function ($table) {
$table->increments('id');
$table->string('name');
$table->timestamps();
});
/**
* Opcional
*/
/*DB::table('packages')->insert(
array(
'package_name' => 'Nombre del paquete',
'icon' => 'fa-cog',// icono de la plantilla
)
);
$packageid = DB::getPdo()->lastInsertId(); */
// agregamos el paquete id al cual queremos que este relacionada
$package_id = 2;
// insertamos en la tabla modules, el nombre de nuestro paquete
DB::table('modules')->insert(array('package_id' => $package_id, 'module_name' => 'Nombre del paquete', 'route' => 'test'));
$module_id = DB::getPdo()->lastInsertId();
// Insertamos los permisos que tendra nuestros modulo
DB::table('module_permissions')->insert([['module_id' => $module_id, 'display_name' => 'ver test', 'permission' => 'test.view'], ['module_id' => $module_id, 'display_name' => 'create test', 'permission' => 'test.create'], ['module_id' => $module_id, 'display_name' => 'actualizar test', 'permission' => 'test.update'], ['module_id' => $module_id, 'display_name' => 'delete test', 'permission' => 'test.delete'], ['module_id' => $module_id, 'display_name' => 'widget test', 'permission' => 'TestWidget.view']]);
}
示例5: upload
public function upload()
{
$input = Input::all();
$validation = Validator::make($input, Template::$rules);
if ($validation->passes()) {
$file = Input::file('image');
// your file upload input field in the form should be named 'file'
$destinationPath = public_path() . '\\templates';
$filename = $file->getClientOriginalName();
//$extension =$file->getClientOriginalExtension(); //if you need extension of the file
$uploadSuccess = Input::file('image')->move($destinationPath, $filename);
$input = Input::all();
if ($uploadSuccess) {
//return Response::json('success', 200); // or do a redirect with some message that file was uploaded
$this->image_thumbnail->t_id = Input::get('t_id');
$this->image_thumbnail->title = Input::get('title');
$this->image_thumbnail->img = $filename;
$this->image_thumbnail->save();
$id = DB::getPdo()->lastInsertId();
return Redirect::route('templates.definefields', array('id' => $id));
//return Redirect::route('image_thumbnail.upload', array('id' => $id));
}
}
return Redirect::route('templates.create')->withInput()->withErrors($validation)->with('message', 'There were validation errors.');
}
示例6: addItem
public function addItem()
{
if (Request::isMethod('post')) {
$insertVal = array('am_name' => Input::get('item_name'), 'am_description' => Input::get('item_desc'), 'am_quantity' => Input::get('stock'), 'am_capacity' => Input::get('capacity'), 'am_price' => str_replace(',', '', Input::get('price')), 'am_group' => Input::get('item_type'));
$this->GlobalModel->insertModel('tbl_amenities', $insertVal);
$lastID = DB::getPdo()->lastInsertId();
if (Input::hasFile('item_image')) {
$files = Input::file('item_image');
$i = 1;
foreach ($files as $file) {
try {
$path = public_path() . '\\uploads\\amenity_type\\';
$extension = $file->getClientOriginalExtension();
$filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
$dateNow = date('Ymd_His');
$new_filename = Auth::user()->id . '_' . $dateNow . '_' . $i . '.' . $extension;
$upload_success = $file->move($path, $new_filename);
} catch (Exception $ex) {
$path = public_path() . '/uploads/amenity_type/';
$extension = $file->getClientOriginalExtension();
$filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
$dateNow = date('Ymd_His');
$new_filename = Auth::user()->id . '_' . $dateNow . '_' . $i . '.' . $extension;
$upload_success = $file->move($path, $new_filename);
}
$insertVal = array('image_fieldvalue' => $lastID, 'image_name' => $new_filename);
$this->GlobalModel->insertModel('tbl_images', $insertVal);
$i++;
}
}
$this->TransLog->transLogger('Amenity Module', 'Added Amenity', $lastID);
}
}
示例7: up
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
$date = new Carbon();
$addRows = [];
foreach (Page::all() as $page) {
if ($page->in_group) {
$addRows[] = ['page_id' => $page->id, 'group_id' => $page->in_group, 'created_at' => $date, 'updated_at' => $date];
}
}
DB::table('page_group_pages')->insert($addRows);
Schema::table('pages', function (Blueprint $table) {
$table->dropColumn('in_group');
$table->integer('group_container_url_priority')->default(0)->after('group_container');
$table->integer('canonical_parent')->default(0)->after('group_container_url_priority');
});
Schema::table('page_group', function (Blueprint $table) {
$table->dropColumn('default_parent');
$table->dropColumn('order_by_attribute_id');
$table->dropColumn('order_dir');
$table->integer('url_priority')->default(50)->after('item_name');
});
Schema::table('page_group_attributes', function (Blueprint $table) {
$table->integer('item_block_order_priority')->default(0)->after('item_block_id');
$table->string('item_block_order_dir')->default('asc')->after('item_block_order_priority');
$table->integer('filter_by_block_id')->default(0)->change();
});
$groupsController = DB::table('admin_controllers')->select('id')->where('controller', '=', 'groups')->first();
DB::table('admin_actions')->insert(array(array('controller_id' => $groupsController->id, 'action' => 'edit', 'inherit' => 0, 'edit_based' => 0, 'name' => 'Edit Group Settings', 'about' => null, 'created_at' => $date, 'updated_at' => $date)));
$lastInsertId = DB::getPdo()->lastInsertId();
DB::table('user_roles_actions')->insert(array(array('role_id' => 2, 'action_id' => $lastInsertId, 'created_at' => $date, 'updated_at' => $date)));
}
示例8: store
/**
* Store a newly created song in storage.
*
* @return Response
*/
public function store()
{
// Set rules for validator
$rules = array("artist" => "required", "title" => "required", "requester" => "required", "link" => "required|url");
// Validate input
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
// TODO: Remember form input...
return Redirect::to('song/create')->withErrors($validator, "song");
}
// Create new song
$song = Input::all();
// Set or unset remember cookie
if (isset($song['remember-requester'])) {
$cookie = Cookie::make("requester", $song['requester']);
} else {
$cookie = Cookie::forget("requester");
}
$artist = DB::getPdo()->quote($song['artist']);
$title = DB::getPdo()->quote($song['title']);
if (Song::whereRaw("LOWER(artist) = LOWER({$artist}) AND LOWER(title) = LOWER({$title})")->count() > 0) {
return Redirect::to('song/create')->with('error', "HEBBEN WE AL!!!")->withCookie($cookie);
}
Song::create($song);
// Set success message
$msg = "Gefeliciteerd! Je nummer is aangevraagd :D";
// Redirect to song index page with message and cookie
return Redirect::to("/")->with("success", $msg)->withCookie($cookie);
}
示例9: up
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
$date = new Carbon();
$themesController = DB::table('admin_controllers')->select('id')->where('controller', '=', 'themes')->first();
DB::table('admin_actions')->insert(array(array('controller_id' => $themesController->id, 'action' => 'selects', 'inherit' => 0, 'edit_based' => 0, 'name' => 'Change Select Block Options', 'about' => null, 'created_at' => $date, 'updated_at' => $date)));
$lastInsertId = DB::getPdo()->lastInsertId();
DB::table('user_roles_actions')->insert(array(array('role_id' => 2, 'action_id' => $lastInsertId, 'created_at' => $date, 'updated_at' => $date)));
}
示例10: uploadBankReceipt
public function uploadBankReceipt()
{
if (Input::hasFile('uploadReceipt')) {
$data = array();
if (is_array(Input::get('room_id'))) {
foreach (Input::get('room_id') as $key => $val) {
$data[$key] = array('am_id' => Input::get('am_id.' . $key), 'rooms' => $val);
}
}
$data2 = array();
if (is_array(Input::get('add_Am'))) {
foreach (Input::get('add_Am') as $key => $val) {
$data2[$key] = array('am_id' => Input::get('am_id.' . $key), 'rooms' => $val);
}
}
$name = Input::get('packname');
$price = Input::get('amount');
$input_dFrom = Input::get('package_datefrom');
$input_dTo = Input::get('package_dateto');
$input_nPax = Input::get('num_pax');
$input_fName = Input::get('fullN');
$postData = new Reservation();
$postData->dataInsertPost($name, $price, $input_dFrom, $input_dTo, $input_nPax, $input_fName, json_encode($data), 'Bank', json_encode($data2));
$lastInsert = DB::getPdo()->lastInsertId();
$files = Input::file('uploadReceipt');
$i = 1;
foreach ($files as $file) {
try {
$path = public_path() . '\\uploads\\bank_deposit\\';
$extension = $file->getClientOriginalExtension();
$filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
$dateNow = date('Ymd_His');
$new_filename = Auth::user()->id . '_' . $filename . '_' . $i . '.' . $extension;
$upload_success = $file->move($path, $new_filename);
} catch (Exception $ex) {
$path = public_path() . '/uploads/bank_deposit/';
$extension = $file->getClientOriginalExtension();
$filename = pathinfo($file->getClientOriginalName(), PATHINFO_FILENAME);
$dateNow = date('Ymd_His');
$new_filename = Auth::user()->id . '_' . $filename . '_' . $i . '.' . $extension;
$upload_success = $file->move($path, $new_filename);
}
$insertVal = array('image_fieldvalue' => $lastInsert, 'image_name' => $new_filename);
$this->GlobalModel->insertModel('tbl_images', $insertVal);
$i++;
}
$data = array('refNumber' => str_pad($lastInsert, 10, "0", STR_PAD_LEFT), 'package' => $name, 'amount' => '₱' . number_format($price, 2), 'paymentMethod' => 'Bank Deposit', 'status' => 1);
try {
Mail::send('emails.user.transactionReservation', $data, function ($message) use($data) {
$message->from('no-reply@reservation.com', 'El Sitio Filipino');
$message->to(Auth::user()->user_email, Auth::user()->user_fname . ' ' . Auth::user()->user_lname)->subject('El Sitio Filipino Transaction Details');
});
} catch (Exception $ex) {
dd($ex->getMessage());
}
return Response::json($data);
}
}
示例11: up
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
$date = new Carbon();
$themesController = DB::table('admin_controllers')->select('id')->where('controller', '=', 'themes')->first();
$indexAction = DB::table('admin_actions')->select('id')->where('controller_id', '=', $themesController->id)->where('action', '=', 'index')->first();
DB::table('admin_actions')->insert(array(array('controller_id' => $themesController->id, 'action' => 'list', 'inherit' => $indexAction->id, 'edit_based' => 0, 'name' => 'View Uploaded Themes', 'about' => null, 'created_at' => $date, 'updated_at' => $date), array('controller_id' => $themesController->id, 'action' => 'export', 'inherit' => 0, 'edit_based' => 0, 'name' => 'Export Uploaded Themes', 'about' => null, 'created_at' => $date, 'updated_at' => $date)));
$lastInsertId = DB::getPdo()->lastInsertId();
DB::table('user_roles_actions')->insert(array(array('role_id' => 2, 'action_id' => $lastInsertId, 'created_at' => $date, 'updated_at' => $date)));
}
示例12: up
/**
* Make changes to the database.
*
* @return void
*/
public function up()
{
$date = new Carbon();
$themesController = DB::table('admin_controllers')->select('id')->where('controller', '=', 'themes')->first();
$updateAction = DB::table('admin_actions')->select('id')->where('controller_id', '=', $themesController->id)->where('action', '=', 'update')->first();
DB::table('admin_actions')->insert(array(array('controller_id' => $themesController->id, 'action' => 'forms', 'inherit' => 0, 'edit_based' => 0, 'name' => 'Change Form Rules', 'about' => null, 'created_at' => $date, 'updated_at' => $date)));
$lastInsertId = DB::getPdo()->lastInsertId();
DB::table('user_roles_actions')->insert(array(array('role_id' => 2, 'action_id' => $updateAction->id, 'created_at' => $date, 'updated_at' => $date), array('role_id' => 2, 'action_id' => $lastInsertId, 'created_at' => $date, 'updated_at' => $date)));
DB::table('admin_actions')->where('controller_id', '=', $themesController->id)->where('action', '=', 'update')->update(['inherit' => 0]);
DB::table('admin_actions')->where('controller_id', '=', $themesController->id)->where('action', '=', 'index')->update(['name' => 'Show Theme Management']);
}
示例13: opponents
public function opponents($tournament)
{
return $players = Player::select(array('*', 'players.id AS id'))->distinct()->join('reports', 'reports.player', '=', 'players.id')->whereRaw('reports.game IN (
SELECT games.id
FROM reports
JOIN games ON games.id = reports.game
JOIN rounds ON rounds.id = games.round
WHERE reports.player = ' . DB::getPdo()->quote($this->id) . '
AND rounds.tournament = ' . DB::getPdo()->quote($tournament->id) . '
)')->where('players.id', '<>', $this->id);
}
示例14: get_last_query
function get_last_query()
{
$queries = DB::getQueryLog();
$sql = end($queries);
if (!empty($sql['bindings'])) {
$pdo = DB::getPdo();
foreach ($sql['bindings'] as $binding) {
$sql['query'] = preg_replace('/\\?/', $pdo->quote($binding), $sql['query'], 1);
}
}
return $sql['query'];
}
示例15: dataInsertPost
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
public function dataInsertPost($name, $price, $input_dFrom, $input_dTo, $input_nPax, $input_fName, $data, $bank = null, $data2)
{
$paymentMethod = $bank == null ? 'PayPal' : 'Bank';
$status = $bank == null ? '1' : '2';
$packName = DB::table('tbl_packages')->where('pc_name', $name)->first();
$insertOrders = DB::table('tbl_orders')->insert(array('order_packageid' => $packName->pc_id, 'order_userid' => Auth::user()->id, 'order_datefrom' => $input_dFrom, 'order_dateto' => $input_dTo, 'order_person_count' => $input_nPax, 'order_datecreated' => date('Y-m-d H:i:s'), 'payment_method' => $paymentMethod));
$lastInsert = DB::getPdo()->lastInsertId();
$insertOrdersRooms = DB::table('tbl_orders_room')->insert(array('or_orderid' => $lastInsert, 'or_roomid' => $data));
$insertOrdersAdded = DB::table('tbl_orders_added')->insert(array('order_addOrderid' => $lastInsert, 'order_add_id' => $data2));
$dataResevInsert = DB::table('tbl_reservation')->insert(array('order_id' => $lastInsert, 'full_name' => $input_fName, 'number_of_person' => $input_nPax, 'total_amount' => $price, 'pack_name' => $name, 'date_time_from' => $input_dFrom, 'date_time_to' => $input_dTo, 'status' => $status, 'created_by' => Auth::user()->id));
return $dataResevInsert;
}