如何进行多次插入,如:
{{1}}
我无法拆分此查询,因为我是从大文本文件中获取它。
答案 0 :(得分:1)
以下是insert
方法的文档块
/**
* Add a table name to the INSERT clause of the query.
*
* Note that you must not mix insert, update, delete and select method calls when building a query.
*
* Usage:
* $query->insert('#__a')->set('id = 1');
* $query->insert('#__a')->columns('id, title')->values('1,2')->values('3,4');
* $query->insert('#__a')->columns('id, title')->values(array('1,2', '3,4'));
*
* @param mixed $table The name of the table to insert data into.
* @param boolean $incrementField The name of the field to auto increment.
*
* @return JDatabaseQuery Returns this object to allow chaining.
*
* @since 11.1
*/
类似
$query->insert('table')
->columns(`fied1`, `field2`, `field3`)
->values(array('one, two, three', 'four, five, six'));
在线我认为你可能在第一个字段名称上有拼写错误,如果我有可能在稍后传入表示不同字段名称数组的变量,我可能会使用$db->quoteName(array('field1', 'field2', field3'))
。