执行原始语句

通过rawQuery可执行原始语句:

  1. <?php
  2. $data = MysqlPool::invoke(function (MysqlObject $db) {
  3. $result = $db->rawQuery('
  4. CREATE TABLE `member` (
  5. `member_id` int(11) NOT NULL AUTO_INCREMENT,
  6. `mobile` varchar(255) DEFAULT NULL,
  7. `name` varchar(255) DEFAULT NULL,
  8. `password` varchar(255) DEFAULT NULL,
  9. PRIMARY KEY (`member_id`)
  10. ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
  11. ');
  12. });

可通过参数绑定方式传值:

  1. <?php
  2. $data = MysqlPool::invoke(function (MysqlObject $db) {
  3. $result = $db->rawQuery('
  4. select * from member where member_id=? and member_id=? and member_id =?;
  5. ',['1','2','3']);
  6. var_dump($db->getLastQuery());
  7. });

将生成语句:

  1. select * from member where member_id='1' and member_id='2' and member_id ='3';