laravel查询数据库 两个字段相等查询方法
发布时间:2019-12-08, 17:50:33 分类:PHP | 编辑 off 网址 | 辅助
图集1/1
正文 537字数 2,054,440阅读
1.在laravel查询中,我们需要查找两个字段相等的值,这种方法不行$data = DB::connection('mysql_branch')->table('branches')
->where('is_usable',1)
->whereRaw('money','amount')->get();
Run code
Cut to clipboard
2.这种也不行
$first_agent = DB::connection('mysql_branch')->table('branches')
->where('is_usable',1)
->whereRaw('money','=','amount')->get();
Run code
Cut to clipboard
3.需要这样查询
$first_agent = DB::connection('mysql_branch')->table('branches')
->where('is_usable',1)
->whereRaw('money=amount')->get();
Run code
Cut to clipboard
(支付宝)给作者钱财以资鼓励 (微信)→
有过 10 条评论 »
textarea一行一个文本框换行
$str = '1 2 3 4 5'; print_r(explode("\n", str_replace("\r\n", "\n", $str))); Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 )
php数组去重
<?php $aa = array("apple", "banana", "pear", "apple", "wail", "watermalon"); $bb = array_unique($aa); print_r($bb); //Array ( [0] => apple [1] => banana [2] => pear [4] => wail [5] => watermalon ) ?>