diff --git a/lib/dao/dao.class.php b/lib/dao/dao.class.php index ab2dab368f..8a4e171163 100755 --- a/lib/dao/dao.class.php +++ b/lib/dao/dao.class.php @@ -473,6 +473,7 @@ class dao /** * Query the sql, return the statement object. * + * @param string $sql * @access public * @return object the PDOStatement object. */ @@ -480,7 +481,15 @@ class dao { if(!empty(dao::$errors)) return new PDOStatement(); // If any error, return an empty statement object to make sure the remain method to execute. - if(empty($sql)) $sql = $this->processSQL(); + if(empty($sql)) + { + $sql = $this->processSQL(); + } + else + { + $this->sqlobj->setSQL($sql); + } + try { $method = $this->method; @@ -551,6 +560,7 @@ class dao /** /* Execute the sql. It's different with query(), which return the stmt object. But this not. * + * @param string $sql * @access public * @return int the modified or deleted records. */ @@ -558,7 +568,15 @@ class dao { if(!empty(dao::$errors)) return new PDOStatement(); // If any error, return an empty statement object to make sure the remain method to execute. - if(empty($sql)) $sql = $this->processSQL(); + if(empty($sql)) + { + $sql = $this->processSQL(); + } + else + { + $this->sqlobj->setSQL($sql); + } + try { $this->reset(); @@ -1649,6 +1667,18 @@ class sql return $this; } + /** + * Set SQL + * + * @param string $sql + * @access public + * @return object the sql object. + */ + public function setSQL($sql = '') + { + $this->sql = $sql; + } + /** * Get the sql string. *