php – 在Laravel中创建一个Insert … Select语句
发布时间:2020-12-14 19:47:36 所属栏目:大数据 来源:网络整理
导读:我需要转换Laravel的这个查询,我有尝试使用Laravel的Eloquont ORM或Queries创建一个Insert … Select语句的问题.我不知道我将如何去创建这个查询. Insert into Demand (Login,Name,ApptTime,Phone,Physician,Location,FormatName,FormatDate,FormatTime,Appt
我需要转换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); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |