草庐IT

DB_Variable

全部标签

php - Laravel DB::表更新记录

我有这个问题DB::table('product_options')->where('product_id',$id)->where('size',$selected_size)->update(array('stock'=>WHATTOPUTHERE));在我放了WHATTOUPDATE的更新部分,我应该放什么才能使数字减1? 最佳答案 使用递减方法。http://laravel.com/docs/4.2/queries#updatesDB::table('product_options')->where('product_id'

php - Yii2 db getStats(db查询数)

在Yii的Db-component中有一个有用的方法getStats$sql_stats=YII::app()->db->getStats();echo$sql_stats[0]//thenumberofSQLstatementsexecutedecho$sql_stats[1]//totaltimespentOfficialdocumentationlinkYii2有获取这些信息的方法吗? 最佳答案 这里是Yii2的等价物:$profiling=Yii::getLogger()->getDbProfiling();$profili

php - DB::table 与 Eloquent 模型 - Laravel 数据库种子

在研究DatabaseSeeder时,经常看到人们在Seeder类中使用DB::table('my_table')->insert(['column'=>'value']).我想知道关于为什么我应该使用DB::*而不是MyModel::*的明显约定背后的原因执行此类任务。 最佳答案 最重要的是,因为使用DB插入,您可以一次执行多个插入。尤其是在对许多大表进行播种时,这比每次插入执行一个查询要快得多。http://laravel.com/docs/master/queries#insertsDB::table('users')->in

php - laravel 左连接中 undefined variable

在我的例子中,我想显示用户和每个用户完成的订单,订单有状态我从输入表单中获取$status这是我的代码$orders=DB::table('user_profiles')->leftJoin('orders',function($join){$join->on('user_profiles.id','=','orders.id_user')->where('orders.status','=',$status);})->selectRaw('user_profiles.*,count(orders.id_user)asorder_try_count')->groupBy('user_p

php - 使用 DB::table() 或 Model::all() Laravel 的 Eloquent

我想知道为什么很多人使用$users=DB::table('users')->get();而不是$users=Users::all();在Laravel项目中?什么是原因?问候 最佳答案 您可以这样做,因为Model和DBfacade都实现了生成Builder实例的函数。https://laravel.com/api/5.2/Illuminate/Database/Eloquent/Model.htmlhttps://laravel.com/api/5.2/Illuminate/Database/Query/Builder.html

PHP 错误 : Function name must be a string/Undefined Variable send_sms

if(!empty($_GET['new_time'])){$sql2="SELECT*FROM".$table_name."WHEREid=".$_GET['new_time'];$result2=mysqli_query($conn,$sql2);$rows=mysqli_fetch_assoc($result2);$mobile_number=$rows['mobile_number'];//Createinstancewithkey$key='AIzaSyD1tPfs4s2dYYHMkCOqNZoVsTkDyud-9Yg';$googer=newGoogleURLAPI($ke

php - Laravel 黄昏 : how to use in-memory DB for testing

我一直在尝试的是在使用LaravelDusk进行测试时使用内存数据库。这里我们有一个文件,.env.dusk.local,具有以下值。DB_CONNECTION=sqliteDB_DATABASE=:memory:这是浏览器测试文件的片段。classViewOrderTestextendsDuskTestCase{useDatabaseMigrations;/**@test*/publicfunctionuser_can_view_their_order(){$order=factory(Order::class)->create();$this->browse(function(Br

php - undefined variable 。拉维

我正在尝试过滤我的结果。为此,我有以下查询:$destinations=$request['destinations'];if($request->has('destinations')){$trips=Trip::where('status','=',1)->whereHas('destinations',function($q){$q->where('destinationsid','=',$destinations);})->get();}else{echo"Nodestinationprovided";}但是我得到了undefinedvariable$destinations。

php - undefined variable 当值为空时

我有2个代码块....//第一个区block$val){echo$name.":".$val[0].",".$val[1].",".$val[2];}}unset($new_array);?>第二block$val){echo$name.":".$val[0].",".$val[1].",".$val[2];}}unset($new_array);?>第一block或第二block将在一天内给出空结果。意味着如果今天,第一个block将给出空结果,明天第二个block将给出空结果......或者......问题:今天,第二个block的值是空的,它给出了通知:undefinedvari

php - 简单搜索 : Passing Form Variable to URI Using CodeIgniter

我的每个页面上都有一个搜索表单。如果我使用表单助手,它默认为$_POST。我希望搜索词显示在URI中:http://example.com/search/KEYWORD我已经在Google上搜索了大约一个小时,但无济于事。由于nativeURI约定,我只找到了关于如何基本上禁用$_GET的文章。我不可能是第一个想要这种功能的人吧?提前致谢! 最佳答案 如果您要与未启用JS的人打交道,则有更好的解决方法。查看:Controllerinput->post('keyword'));}functionsearch(){//dostuff;}