解析为SQL语句
string Module_Database::compile( [ string $type = string(6) "select" , boolean $use_master = null ] )
参数列表
参数 类型 描述 默认值 $type
string
Select,insert,update,delect,replace string(6) "select" $use_master
boolean
当$type=select此参数有效,设置true则使用主数据库,设置false则使用从数据库,不设置则使用默认 null
string
public function compile($type = 'select', $use_master = null)
{
if ( $type=='select' && null === $use_master && true === $this->is_auto_use_master )
{
$use_master = true;
}
# 先连接数据库,因为在compile时需要用到mysql_real_escape_string,mysqli_real_escape_string方法
$this->driver->connect($use_master);
# 获取查询SQL
$sql = $this->driver->compile($this->_builder, $type);
# 重置QueryBulider
$this->reset();
return $sql;
}