本文整理汇总了PHP中Illuminate\Support\Facades\DB::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::insert方法的具体用法?PHP DB::insert怎么用?PHP DB::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\DB
的用法示例。
在下文中一共展示了DB::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpBeforeClass
public static function setUpBeforeClass()
{
if (!isset(self::$app)) {
self::$app = AppFactory::create();
}
if (!Schema::hasTable('users')) {
Schema::create('users', function ($table) {
$table->increments('id');
$table->string('name');
});
}
DB::insert('insert into users (name) values (?)', array('Test User'));
if (!Schema::hasTable('posts')) {
Schema::create('posts', function ($table) {
$table->increments('id');
$table->string('title');
$table->integer('created_by')->unsigned()->nullable();
$table->integer('updated_by')->unsigned()->nullable();
$table->integer('deleted_by')->unsigned()->nullable();
$table->timestamps();
$table->timestamp('deleted_at')->nullable();
$table->foreign('created_by')->references('id')->on('users');
$table->foreign('updated_by')->references('id')->on('users');
$table->foreign('deleted_by')->references('id')->on('users');
});
}
}
示例2: run
public function run()
{
DB::insert('insert into produtos (nome, quantidade, valor, descricao, created_at, updated_at) values (?,?,?,?,?,?)', array('Geladeira', 2, 590.0, 'Side by side com gelo na porta', '2015-07-01', '2015-07-01'));
DB::insert('insert into produtos (nome, quantidade, valor, descricao, created_at, updated_at) values (?,?,?,?,?,?)', array('Fogão', 5, 950.0, 'Painel Automatico e forno eletrico', '2015-07-01', '2015-07-01'));
DB::insert('insert into produtos (nome, quantidade, valor, descricao, created_at, updated_at) values (?,?,?,?,?,?)', array('Microondas', 1, 250.0, 'Manda sms quando termina de esquentar', '2015-07-01', '2015-07-01'));
DB::insert('insert into produtos (nome, quantidade, valor, descricao, created_at, updated_at) values (?,?,?,?,?,?)', array('Cama Box Casal', 3, 340.0, 'Excelente Cama', '2015-07-01', '2015-07-01'));
}
示例3: duzenleForm
public function duzenleForm($id)
{
$data = Input::all();
$kural = array('baslik' => 'required|min:3', 'resim' => 'max:1536|required|mimes:jpeg,jpg,bmp,png,gif');
$dogrulama = \Validator::Make($data, $kural);
if (!$dogrulama->passes()) {
return \Redirect::to('admin/galeriler/duzenle/' . $id)->withErrors($dogrulama)->withInput();
} else {
if (Input::hasFile('resim')) {
$dosya = Input::file('resim');
$uzanti = $dosya->getClientOriginalExtension();
if (strlen($uzanti) == 3) {
$dosyaAdi = substr($dosya->getClientOriginalName(), 0, -4);
} else {
if (strlen($uzanti) == 4) {
$dosyaAdi = substr($dosya->getClientOriginalName(), 0, -5);
}
}
$dosyaAdi = $dosyaAdi . "_" . date('YmdHis') . '.' . $uzanti;
$path = base_path('galeriResimler/600x450/' . $dosyaAdi);
Image::make($dosya->getRealPath())->resize(600, 450)->save($path);
$path = base_path('galeriResimler/defaultSize/' . $dosyaAdi);
Image::make($dosya->getRealPath())->save($path);
$path = $dosyaAdi;
$query = DB::insert('insert into gal_resim values (null,?,?,?)', array($id, $data["baslik"], $path));
return Redirect::back();
}
}
}
示例4: importdata
public function importdata(Request $request)
{
$results = null;
$type = $request->input('type');
$retdate = Excel::load($request->file('exelimport'), function ($reader) use($type) {
$results = $reader->get();
$ret = $results->toArray();
// var_dump($ret);
foreach ($ret as $index => $value) {
$EMP_ID = $value["emp_id"];
$PLAN_ID = $value["plan_id"];
$EQUITY_RATE = $value["equity_rate"];
$DEBT_RATE = $value["debt_rate"];
$MODIFY_DATE = $value["modify_date"];
$EFFECTIVE_DATE = $value["effective_date"];
$MODIFY_COUNT = $value["modify_count"];
$MODIFY_COUNT_TIMESTAMP = $value["modify_count_timestamp"];
$MODIFY_BY = $value["modify_by"];
$insert = "INSERT INTO TBL_USER_FUND_CHOOSE (PLAN_ID,EMP_ID,EQUITY_RATE,DEBT_RATE,MODIFY_DATE,EFFECTIVE_DATE,MODIFY_COUNT,MODIFY_COUNT_TIMESTAMP,MODIFY_BY) VALUES(" . $PLAN_ID . ",'" . $EMP_ID . "'," . $EQUITY_RATE . "," . $DEBT_RATE . ",'" . $MODIFY_DATE . "','" . $EFFECTIVE_DATE . "'," . $MODIFY_COUNT . ",'" . $MODIFY_COUNT_TIMESTAMP . "','" . $MODIFY_BY . "')";
DB::insert(DB::raw($insert));
}
$staturet = true;
$data = "ok";
});
return response()->json(array('success' => true, 'html' => $retdate));
}
示例5: testTransaction
public function testTransaction()
{
DB::beginTransaction();
DB::insert('insert into users (name,email,password) values (?,?,?)', ['ceshi', '728686686@qq.com', 'ddddd']);
// DB::rollback();
DB::commit();
}
示例6: ekle
public function ekle()
{
$yukseklik = $_POST["yukseklik"];
$genislik = $_POST["genislik"];
// $data = Input::all();
// //$id = $data["id"];
// // Validasyonlar
// $kural = array(
// 'ad'=>'required',
// 'yol'=>'required',
// 'genislik'=>'required',
// 'yukseklik'=>'required',
// 'url'=>'required',
// 'durum'=>'required');
// $dogrulama = \Validator::Make($data,$kural);
// if($dogrulama->fails()){
// // gönderilen verilerde hata var
// return \Redirect::to('admin/bannerEkle')->withErrors($dogrulama)->withInput();
// } else {
if (isset($_POST["ekle"])) {
$dosya = Input::file('dosya');
$data = Input::all();
$uzanti = $dosya->getClientOriginalExtension();
$dosyaAdi = date('YmdHis') . "_b." . $uzanti;
$path = base_path('bannerResimler/' . $dosyaAdi);
$imagePath = 'bannerResimler/' . $dosyaAdi;
Image::make($dosya->getRealPath())->resize($genislik, $yukseklik)->save($path);
DB::insert("insert into banner values (null, ?,?,?,?,?,?,?,?,?,?,?)", array($data["adi"], '0', $data["yukseklik"], $data["genislik"], $dosyaAdi, $data["link"], '0', '0', $data["baslangic"], $data["bitis"], $data["durum"]));
return Redirect('admin/bannerListele');
}
}
示例7: setData
public function setData()
{
$humidity = Request::input("h");
$temperature = Request::input("t");
$slaveName = Request::input("s");
$addedOn = date("Y-m-d H:i:s");
$methane = Request::input("m");
$carbonMon = Request::input("cm");
try {
DB::insert("insert into humidities (slave_name, humidity, added_on) values (?,?,?)", [$slaveName, $humidity, $addedOn]);
DB::insert("insert into temperatures (slave_name, temperature, added_on) values (?,?,?)", [$slaveName, $temperature, $addedOn]);
if (isset($methane)) {
DB::insert("insert into methane (methane_value, added_on) values (?,?)", [$methane, $addedOn]);
}
if (isset($carbonMon)) {
DB::insert("insert into carbon_monoxide (carbon_value, added_on) values (?,?)", [$carbonMon, $addedOn]);
}
$data = array("status" => "success");
header("Access-Control-Allow-Origin: *");
return json_encode($data);
} catch (QueryException $e) {
$data = array("status" => $e->getMessage());
header("Access-Control-Allow-Origin: *");
return json_encode($data);
}
}
示例8: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
//class ProdutoTableSeeder extends Seeder {
DB::insert('insert into produtos (nome, quantidade, valor, descricao) values (?,?,?,?)', array('Geladeira', 2, 5900.0, 'Side by Side com gelo na porta'));
DB::insert('insert into produtos (nome, quantidade, valor, descricao) values (?,?,?,?)', array('Fogão', 5, 950.0, 'Painel automático e forno elétrico'));
DB::insert('insert into produtos (nome, quantidade, valor, descricao) values (?,?,?,?)', array('Microondas', 1, 1520.0, 'Manda SMS quando termina de esquentar'));
}
示例9: recreate
public function recreate()
{
$last = DB::select("SELECT * FROM statuses ORDER BY session_ended DESC LIMIT 1");
if (sizeof($last)) {
$session = $last[0];
DB::insert("INSERT INTO statuses (ip, isp1, isp2, session_started, session_ended) VALUES ('" . $session->ip . "', '" . $session->isp1 . "', '" . $session->isp2 . "', NOW(), NOW())");
}
}
示例10: insertSections
public function insertSections()
{
$insertString = 'insert into sections (slug, shortname, name) values (?, ?, ?)';
$defaultSections = [['news', 'News', 'News'], ['opinion', 'Opinion', 'Opinion'], ['features', 'Features', 'Features'], ['arts-entertainment', 'Arts & Entertainment', 'A&E'], ['sports', 'Sports', 'Sports']];
foreach ($defaultSections as $sectionArray) {
DB::insert($insertString, $sectionArray);
}
}
示例11: insertRecords
/**
* Insert all Genus/Species into the BOLD table.
*
* @param array $genusSpeciesList
* An array of the Genus/Species list.
*
* @return void
*/
public function insertRecords($genusSpeciesList)
{
foreach ($genusSpeciesList as $gs) {
DB::insert('INSERT INTO bold (genus_species) VALUES (?)', [$gs]);
}
Log::info("Done adding records to the BOLD table.");
print "Done adding records to the BOLD table." . PHP_EOL;
}
示例12: insert
/**
* INSERT query
* @param array $content array onde keys são os campos da tabela
* e values as informações que serão inseridas
*/
public function insert(array $content)
{
$this->validateTable();
$keys = $this->getKeysSQLFormated($content);
$values = $this->getValuesSQLFormated($content);
$query = 'INSERT INTO ' . $this->table_name . '(' . $keys . ') VALUES(' . $values . ')';
return DB::insert($query);
}
示例13: ekle
public function ekle()
{
$data = Input::all();
var_dump($data);
$ekle = DB::insert("insert into kullanicilar(id,adi,soyadi,mail,sifre,tarih) values(null,?,?,?,?,now())", array($data["adi"], $data["soyadi"], $data["mail"], $data["sifre"]));
//return view('liste');
return Redirect::to('veritabani');
// Bu da bir yönlendirme işlemidir . to sayesinde .
}
示例14: run
public function run()
{
DB::insert('insert into produtos(nome, quantidade, valor, descricao)
values(?, ?, ?, ?)', array('Geladeira', 2, 5900.0, 'Side by Side com gelo na porta'));
DB::insert('insert into produtos(nome, quantidade, valor, descricao)
values(?, ?, ?, ?)', array('Fogao', 5, 950.0, 'Painel automatico e forno eletrico'));
DB::insert('insert into produtos(nome, quantidade, valor, descricao)
values(?, ?, ?, ?)', array('Microondas', 1, 1520.0, 'Manda sms quando termina de esquentar'));
}
示例15: create
static function create($game)
{
DB::insert('INSERT INTO Games(name, num_players, nickname_field, multicampus) VALUES (:name, :num_players, :nickname_field, :multicampus)', $game);
$id = DB::getPdo()->lastInsertId();
// if (!empty($game->extra_fields)) {
// this.insertFields($id, $game->extra_fields);
// }
return $id;
}