/** * 用此方法拼接成一个select的sql语句;[PS:此方法终结了连贯操作,置于连贯操作的最后面] */ functionselect(){ //按照select语法拼接sql字符串[PS:可以在mysql命令行中执行"help select;"查看其语法构结] $sql="SELECT {$this->sql['field']} FROM test {$this->sql['where']}{$this->sql['group']}{$this->sql['having']}{$this->sql['order']}{$this->sql['limit']}"; echo$sql; } }
调用方式
1 2 3
$obj=new db(); $obj->field('name,sex,address')->where('where name="gongwen"')->limit('limit 1')->select(); //输出:SELECT name,sex,address FROM test where name=gongwen limit 1