/** *执行当前查询 * * 执行当前查询—用提供的参数代替任何点位符 * . * * @参数: mixed $queryParams,... 查询参数 * @返回:资源A—参考描述执行查询的资源。 */ public function execute($queryParams = '') { //例如: SELECT * FROM table WHERE name=:1S AND type=:2I AND level=:3N $args = func_get_args(); if ($this->stored_procedure) { /*调用compile函数以得到查询*/ $query = call_user_func_array(array($this, 'compile'), $args); } else { /*一个存储过程没被初始化,因此,作为一种标准查询来执行之*/ $query = $queryParams; } $result = $this->db->query($query); if (! $result) { throw new QueryException($this); } $this->result = $result; /* 注意现在我们怎么返回对象本身,这使我们能够从这个函数的返回结果中调用成员函数 */ return $this; } |