Index: kernel/db/db_connection.php =================================================================== --- kernel/db/db_connection.php (revision 15906) +++ kernel/db/db_connection.php (working copy) @@ -18,7 +18,7 @@ * Multi database connection class * */ - class kDBConnection extends kBase { + class kDBConnection extends kBase implements IDBConnection { /** * Current database type @@ -744,8 +744,6 @@ return !$this->hasError(); } - - /** * Returns auto increment field value from * insert like operation if any, zero otherwise Index: kernel/db/db_load_balancer.php =================================================================== --- kernel/db/db_load_balancer.php (revision 15906) +++ kernel/db/db_load_balancer.php (working copy) @@ -14,7 +14,7 @@ defined('FULL_PATH') or die('restricted access!'); -class kDBLoadBalancer extends kBase { +class kDBLoadBalancer extends kBase implements IDBConnection { /** * Current database type @@ -599,6 +599,48 @@ } /** + * Returns auto increment field value from + * insert like operation if any, zero otherwise + * + * @return int + * @access public + */ + public function getInsertID() + { + $conn =& $this->openConnection($this->lastUsedIndex); + + return $conn->getInsertID(); + } + + /** + * Returns row count affected by last query + * + * @return int + * @access public + */ + public function getAffectedRows() + { + $conn =& $this->openConnection($this->lastUsedIndex); + + return $conn->getAffectedRows(); + } + + /** + * Returns LIMIT sql clause part for specific db + * + * @param int $offset + * @param int $rows + * @return string + * @access public + */ + public function getLimitClause($offset, $rows) + { + $conn =& $this->openConnection($this->lastUsedIndex); + + return $conn->getLimitClause($offset, $rows); + } + + /** * If it's a string, adds quotes and backslashes (only work since PHP 4.3.0) * Otherwise returns as-is * @@ -628,6 +670,46 @@ } /** + * Escapes strings (only work since PHP 4.3.0) + * + * @param mixed $string + * @return string + * @access public + */ + public function escape($string) + { + $conn =& $this->openConnection($this->lastUsedIndex); + + return $conn->escape($string); + } + + /** + * Returns last error code occurred + * + * @return int + * @access public + */ + public function getErrorCode() + { + $conn =& $this->openConnection($this->lastUsedIndex); + + return $conn->getErrorCode(); + } + + /** + * Returns last error message + * + * @return string + * @access public + */ + public function getErrorMsg() + { + $conn =& $this->openConnection($this->lastUsedIndex); + + return $conn->getErrorMsg(); + } + + /** * Performs insert of given data (useful with small number of queries) * or stores it to perform multiple insert later (useful with large number of queries) * @@ -662,6 +744,48 @@ } /** + * Allows to detect table's presence in database + * + * @param string $table_name + * @param bool $force + * @return bool + * @access public + */ + public function TableFound($table_name, $force = false) + { + $conn =& $this->openConnection($this->lastUsedIndex); + + return $conn->TableFound($table_name, $force); + } + + /** + * Returns query processing statistics + * + * @return Array + * @access public + */ + public function getQueryStatistics() + { + $conn =& $this->openConnection($this->lastUsedIndex); + + return $conn->getQueryStatistics(); + } + + /** + * Get status information from SHOW STATUS in an associative array + * + * @param string $which + * @return Array + * @access public + */ + public function getStatus($which = '%') + { + $conn =& $this->openConnection($this->lastUsedIndex); + + return $conn->getStatus($which); + } + + /** * When undefined method is called, then send it directly to last used slave server connection * * @param string $name @@ -705,4 +829,17 @@ return $conn; } + + /** + * Get slave replication lag. It will only work if the DB user has the PROCESS privilege. + * + * @return int + * @access public + */ + public function getSlaveLag() + { + $conn =& $this->openConnection($this->lastUsedIndex); + + return $conn->getSlaveLag(); + } } Index: kernel/db/i_db_connection.php =================================================================== --- kernel/db/i_db_connection.php (revision 0) +++ kernel/db/i_db_connection.php (revision 0) @@ -0,0 +1,37 @@ +