@H_
404_0@
我需要转换Laravel的这个
查询,我有尝试使用Laravel的Eloquont ORM或Queries创建一个Insert … Select语句的问题.我不知道我将如何去创建这个
查询.
Insert into Demand (Login,Name,ApptTime,Phone,Physician,Location,FormatName,FormatDate,FormatTime,ApptDate,FormatPhone,cellphone)
Select Login,cellphone from " . [dbname] . "
Where " . $where_statement
如何使用Laravel的ORM创建此查询?
编辑:我不知道这是否清楚,但我正在考虑1个查询,就像他们在这里做的一样
没有办法在一个
查询中执行此操作,但是我遇到同一个问题,并希望确保我可以继续使用与QueryBuilder进行一定的选择.
那么你可以做些什么,把事情放在一半干净的地方,重用以前已经构建了select语句的功能呢?
/**
* Wherever your Select may come from
**/
$select = User::where(...)
->where(...)
->whereIn(...)
->select(array('email','moneyOwing'));
/**
* get the binding parameters
**/
$bindings = $select->getBindings();
/**
* now go down to the "Network Layer"
* and do a hard coded select,Laravel is a little
* stupid here
*/
$insertQuery = 'INSERT into user_debt_collection (email,dinero) '
. $select->tosql();
\DB::insert($insertQuery,$bindings);