Index: branches/5.3.x/core/kernel/db/i_db_connection.php =================================================================== diff -u -N -r15919 -r15922 --- branches/5.3.x/core/kernel/db/i_db_connection.php (.../i_db_connection.php) (revision 15919) +++ branches/5.3.x/core/kernel/db/i_db_connection.php (.../i_db_connection.php) (revision 15922) @@ -21,33 +21,135 @@ interface IDBConnection { /** - * Performs sql query, that will change database content + * Checks if previous query execution raised an error. * + * @return bool + * @access public + */ + public function hasError(); + + /** + * Checks if connection to database is opened. + * + * @return bool + * @access public + */ + public function connectionOpened(); + + /** + * Setups the connection according given configuration. + * + * @param Array $config + * @return bool + * @access public + */ + public function setup($config); + + /** + * Returns first field of first line of recordset if query ok or false otherwise. + * * @param string $sql + * @param int $offset + * @return string + * @access public + */ + public function GetOne($sql, $offset = 0); + + /** + * Returns first row of recordset if query ok, false otherwise. + * + * @param string $sql + * @param int $offset + * @return Array + * @access public + */ + public function GetRow($sql, $offset = 0); + + /** + * 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 + * @access public + */ + public function GetCol($sql, $key_field = null); + + /** + * 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. + * + * @param string $sql + * @param string $key_field + * @return bool|kMySQLQueryCol + */ + public function GetColIterator($sql, $key_field = null); + + /** + * 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 + * @return Array + * @access public + */ + public function Query($sql, $key_field = null, $no_debug = false); + + /** + * 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 string $iterator_class + * @return kMySQLQuery|bool + * @access public + */ + public function GetIterator($sql, $key_field = null, $no_debug = false, $iterator_class = 'kMySQLQuery'); + + /** + * Free memory used to hold recordset handle. + * + * @access public + */ + public function Destroy(); + + /** + * Performs sql query, that will change database content. + * + * @param string $sql * @return bool * @access public */ public function ChangeQuery($sql); /** - * Returns auto increment field value from - * insert like operation if any, zero otherwise + * Returns auto increment field value from insert like operation if any, zero otherwise. * * @return int * @access public */ public function getInsertID(); /** - * Returns row count affected by last query + * Returns row count affected by last query. * * @return int * @access public */ public function getAffectedRows(); /** - * Returns LIMIT sql clause part for specific db + * Returns LIMIT sql clause part for specific db. * * @param int $offset * @param int $rows @@ -57,8 +159,7 @@ public function getLimitClause($offset, $rows); /** - * If it's a string, adds quotes and backslashes (only work since PHP 4.3.0) - * Otherwise returns as-is + * If it's a string, adds quotes and backslashes. Otherwise returns as-is. * * @param mixed $string * @return string @@ -67,7 +168,7 @@ public function qstr($string); /** - * Calls "qstr" function for each given array element + * Calls "qstr" function for each given array element. * * @param Array $array * @param string $function @@ -76,7 +177,7 @@ public function qstrArray($array, $function = 'qstr'); /** - * Escapes strings (only work since PHP 4.3.0) + * Escapes string. * * @param mixed $string * @return string @@ -85,15 +186,15 @@ public function escape($string); /** - * Returns last error code occurred + * Returns last error code occurred. * * @return int * @access public */ public function getErrorCode(); /** - * Returns last error message + * Returns last error message. * * @return string * @access public @@ -102,7 +203,7 @@ /** * 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 @@ -114,7 +215,7 @@ public function doInsert($fields_hash, $table, $type = 'INSERT', $insert_now = true); /** - * 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 @@ -125,7 +226,7 @@ public function doUpdate($fields_hash, $table, $key_clause); /** - * Allows to detect table's presence in database + * Allows to detect table's presence in database. * * @param string $table_name * @param bool $force @@ -135,15 +236,15 @@ public function TableFound($table_name, $force = false); /** - * Returns query processing statistics + * Returns query processing statistics. * * @return Array * @access public */ public function getQueryStatistics(); /** - * Get status information from SHOW STATUS in an associative array + * Get status information from SHOW STATUS in an associative array. * * @param string $which * @return Array Index: branches/5.3.x/core/kernel/db/db_load_balancer.php =================================================================== diff -u -N -r15919 -r15922 --- branches/5.3.x/core/kernel/db/db_load_balancer.php (.../db_load_balancer.php) (revision 15919) +++ branches/5.3.x/core/kernel/db/db_load_balancer.php (.../db_load_balancer.php) (revision 15922) @@ -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,8 +626,7 @@ } /** - * Returns auto increment field value from - * insert like operation if any, zero otherwise + * Returns auto increment field value from insert like operation if any, zero otherwise. * * @return int * @access public @@ -613,7 +639,7 @@ } /** - * Returns row count affected by last query + * Returns row count affected by last query. * * @return int * @access public @@ -626,7 +652,7 @@ } /** - * Returns LIMIT sql clause part for specific db + * Returns LIMIT sql clause part for specific db. * * @param int $offset * @param int $rows @@ -641,8 +667,7 @@ } /** - * If it's a string, adds quotes and backslashes (only work since PHP 4.3.0) - * Otherwise returns as-is + * If it's a string, adds quotes and backslashes. Otherwise returns as-is. * * @param mixed $string * @return string @@ -656,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 @@ -670,7 +695,7 @@ } /** - * Escapes strings (only work since PHP 4.3.0) + * Escapes string. * * @param mixed $string * @return string @@ -684,7 +709,7 @@ } /** - * Returns last error code occurred + * Returns last error code occurred. * * @return int * @access public @@ -697,7 +722,7 @@ } /** - * Returns last error message + * Returns last error message. * * @return string * @access public @@ -711,7 +736,7 @@ /** * 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 @@ -728,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 @@ -744,7 +769,7 @@ } /** - * Allows to detect table's presence in database + * Allows to detect table's presence in database. * * @param string $table_name * @param bool $force @@ -759,7 +784,7 @@ } /** - * Returns query processing statistics + * Returns query processing statistics. * * @return Array * @access public @@ -772,7 +797,7 @@ } /** - * Get status information from SHOW STATUS in an associative array + * Get status information from SHOW STATUS in an associative array. * * @param string $which * @return Array Index: branches/5.3.x/core/kernel/db/db_connection.php =================================================================== diff -u -N -r15919 -r15922 --- branches/5.3.x/core/kernel/db/db_connection.php (.../db_connection.php) (revision 15919) +++ branches/5.3.x/core/kernel/db/db_connection.php (.../db_connection.php) (revision 15922) @@ -1,6 +1,6 @@ dbType . '_' . $name; } - /** - * Try to connect to database server - * using specified parameters and set - * database to $db if connection made + * Try to connect to database server using specified parameters and set database to $db if connection made. * * @param string $host * @param string $user * @param string $pass * @param string $db - * @param bool $force_new - * @param bool $retry + * @param bool $force_new + * @param bool $retry + * * @return bool * @access public + * @throws RuntimeException When connection failed. */ public function Connect($host, $user, $pass, $db, $force_new = false, $retry = false) { @@ -314,7 +312,7 @@ } /** - * Checks if connection to database is opened + * Checks if connection to database is opened. * * @return bool * @access public @@ -325,7 +323,7 @@ } /** - * Setups the connection according given configuration + * Setups the connection according given configuration. * * @param Array $config * @return bool @@ -499,9 +497,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 @@ -520,8 +516,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 @@ -541,12 +536,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 @@ -581,9 +574,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 @@ -594,12 +587,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 @@ -663,13 +654,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 @@ -718,7 +710,7 @@ } /** - * Free memory used to hold recordset handle + * Free memory used to hold recordset handle. * * @access public */ @@ -731,7 +723,7 @@ } /** - * Performs sql query, that will change database content + * Performs sql query, that will change database content. * * @param string $sql * @return bool @@ -745,8 +737,7 @@ } /** - * Returns auto increment field value from - * insert like operation if any, zero otherwise + * Returns auto increment field value from insert like operation if any, zero otherwise. * * @return int * @access public @@ -758,7 +749,7 @@ } /** - * Returns row count affected by last query + * Returns row count affected by last query. * * @return int * @access public @@ -770,7 +761,7 @@ } /** - * Returns LIMIT sql clause part for specific db + * Returns LIMIT sql clause part for specific db. * * @param int $offset * @param int $rows @@ -791,8 +782,7 @@ } /** - * If it's a string, adds quotes and backslashes (only work since PHP 4.3.0) - * Otherwise returns as-is + * If it's a string, adds quotes and backslashes. Otherwise returns as-is. * * @param mixed $string * @return string @@ -812,7 +802,7 @@ } /** - * Calls "qstr" function for each given array element + * Calls "qstr" function for each given array element. * * @param Array $array * @param string $function @@ -824,7 +814,7 @@ } /** - * Escapes strings (only work since PHP 4.3.0) + * Escapes string. * * @param mixed $string * @return string @@ -843,7 +833,7 @@ } /** - * Returns last error code occurred + * Returns last error code occurred. * * @return int * @access public @@ -854,7 +844,7 @@ } /** - * Returns last error message + * Returns last error message. * * @return string * @access public @@ -866,7 +856,7 @@ /** * 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 @@ -909,7 +899,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 @@ -935,7 +925,7 @@ } /** - * Allows to detect table's presence in database + * Allows to detect table's presence in database. * * @param string $table_name * @param bool $force @@ -967,7 +957,7 @@ } /** - * Returns query processing statistics + * Returns query processing statistics. * * @return Array * @access public @@ -978,7 +968,7 @@ } /** - * Get status information from SHOW STATUS in an associative array + * Get status information from SHOW STATUS in an associative array. * * @param string $which * @return Array @@ -1081,12 +1071,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 @@ -1164,13 +1152,14 @@ } /** - * 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