$builder = Yii::app()->db->schema->commandBuilder; // 创建builder对象 $command = $builder->createMultipleInsertCommand('{{umeng_message}}', array( // umeng_message为数据库表 array(// 格式为:'字段' => '值', 不包括主键ID,一个array为一条记录 'msg_id' => $android['data']['task_id'], 'detail' => $android['data']['json'], 'msg_detail_id_fk' => $detailId ), array( 'msg_id' => $android['data']['task_id'], 'detail' => $android['data']['json'], 'msg_detail_id_fk' => $detailId ), )); $command->execute(); // 执行成功返回true
参考:
http://www.yiiframework.com/doc/api/1.1/CDbCommandBuilder#createMultipleInsertCommand-detail