Index: branches/5.2.x/core/kernel/db/db_load_balancer.php =================================================================== diff -u -N -r16407 -r16432 --- branches/5.2.x/core/kernel/db/db_load_balancer.php (.../db_load_balancer.php) (revision 16407) +++ branches/5.2.x/core/kernel/db/db_load_balancer.php (.../db_load_balancer.php) (revision 16432) @@ -1,6 +1,6 @@ openConnection($this->lastUsedIndex); + + return $conn->hasError(); + } + + /** + * Checks if connection to the server given by the specified index is opened. + * * @param integer $i Server index * @return bool * @access public @@ -486,7 +499,7 @@ } /** - * Returns first field of first line of recordset if query ok or false otherwise + * Returns first field of first line of recordset if query ok or false otherwise. * * @param string $sql * @param int $offset @@ -501,7 +514,7 @@ } /** - * Returns first row of recordset if query ok, false otherwise + * Returns first row of recordset if query ok, false otherwise. * * @param string $sql * @param int $offset @@ -516,9 +529,10 @@ } /** - * Returns 1st column of recordset as one-dimensional array or false otherwise - * Optional parameter $key_field can be used to set field name to be used as resulting array key + * Returns 1st column of recordset as one-dimensional array or false otherwise. * + * Optional parameter $key_field can be used to set field name to be used as resulting array key. + * * @param string $sql * @param string $key_field * @return Array @@ -533,9 +547,9 @@ /** * Returns iterator for 1st column of a recordset or false in case of error. - * Optional parameter $key_field can be used to set field name to be used - * as resulting array key. * + * Optional parameter $key_field can be used to set field name to be used as resulting array key. + * * @param string $sql * @param string $key_field * @return bool|kMySQLQueryCol @@ -548,10 +562,10 @@ } /** - * Queries db with $sql query supplied and returns rows selected if any, false - * otherwise. Optional parameter $key_field allows to set one of the query fields - * value as key in string array. + * Queries db with $sql query supplied and returns rows selected if any, false otherwise. * + * Optional parameter $key_field allows to set one of the query fields value as key in string array. + * * @param string $sql * @param string $key_field * @param bool $no_debug @@ -566,13 +580,14 @@ } /** - * Returns iterator to a recordset, produced from running $sql query Queries db with $sql query supplied and returns kMySQLQuery iterator - * or false in case of error. Optional parameter $key_field allows to - * set one of the query fields value as key in string array. + * Returns iterator to a recordset, produced from running $sql query. * + * Queries db with $sql query supplied and returns kMySQLQuery iterator or false in case of error. + * Optional parameter $key_field allows to set one of the query fields value as key in string array. + * * @param string $sql * @param string $key_field - * @param bool $no_debug + * @param bool $no_debug * @param string $iterator_class * @return kMySQLQuery|bool * @access public @@ -585,8 +600,20 @@ } /** - * Performs sql query, that will change database content + * Free memory used to hold recordset handle. * + * @access public + */ + public function Destroy() + { + $conn =& $this->openConnection($this->lastUsedIndex); + + $conn->Destroy(); + } + + /** + * Performs sql query, that will change database content. + * * @param string $sql * @return bool * @access public @@ -599,9 +626,49 @@ } /** - * If it's a string, adds quotes and backslashes (only work since PHP 4.3.0) - * Otherwise returns as-is + * 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. Otherwise returns as-is. + * * @param mixed $string * @return string * @access public @@ -614,7 +681,7 @@ } /** - * Calls "qstr" function for each given array element + * Calls "qstr" function for each given array element. * * @param Array $array * @param string $function @@ -628,8 +695,48 @@ } /** + * Escapes string. + * + * @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) + * or stores it to perform multiple insert later (useful with large number of queries). * * @param Array $fields_hash * @param string $table @@ -646,7 +753,7 @@ } /** - * Update given field values to given record using $key_clause + * Update given field values to given record using $key_clause. * * @param Array $fields_hash * @param string $table @@ -662,6 +769,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 +854,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(); + } }