查询语言.table

函数原型

  1. public function table($mixTable, $mixCols = '*');

指定数据表

  1. # SELECT `posts`.* FROM `posts`
  2. Db::table('posts')->
  3. getAll();
  4. # SELECT `posts`.* FROM `mydb`.`posts`
  5. Db::table('mydb.posts')->
  6. getAll();
  7. # SELECT `p`.* FROM `mydb`.`posts` `p`
  8. Db::table(['p' => 'mydb.posts'])->
  9. getAll();

指定字段

  1. # SELECT `posts`.`title`,`posts`.`body` FROM `posts`
  2. Db::table('posts','title,body')->getAll();
  3. # SELECT `posts`.`title` AS `t`,`posts`.`name`,`posts`.`remark`,`posts`.`value` FROM `mydb`.`posts`
  4. Db::table(
  5. 'mydb.posts',
  6. ['t'=> 'title','name','remark,value']
  7. )->
  8. getAll();