Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/kernel/db/db_load_balancer.php
Show First 20 Lines • Show All 100 Lines • ▼ Show 20 Line(s) | |||||
* Indicates, that next database query could be cached, when memory caching is enabled | * Indicates, that next database query could be cached, when memory caching is enabled | ||||
* | * | ||||
* @var bool | * @var bool | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public $nextQueryCachable = false; | public $nextQueryCachable = false; | ||||
/** | /** | ||||
* The "no debugging" tate of the SQL queries. | |||||
* | |||||
* @var boolean | |||||
*/ | |||||
public $noDebuggingState = false; | |||||
/** | |||||
* Indicates, that next query should be sent to maser database | * Indicates, that next query should be sent to maser database | ||||
* | * | ||||
* @var bool | * @var bool | ||||
*/ | */ | ||||
public $nextQueryFromMaster = false; | public $nextQueryFromMaster = false; | ||||
/** | /** | ||||
* Creates new instance of load balancer class | * Creates new instance of load balancer class | ||||
▲ Show 20 Lines • Show All 320 Lines • ▼ Show 20 Line(s) | |||||
$this->connections[$i] =& $conn; | $this->connections[$i] =& $conn; | ||||
$this->lastUsedIndex = $i; | $this->lastUsedIndex = $i; | ||||
} | } | ||||
else { | else { | ||||
$conn = false; | $conn = false; | ||||
} | } | ||||
} | } | ||||
if ( $this->nextQueryCachable && is_object($conn) ) { | if ( is_object($conn) ) { | ||||
$conn->noDebuggingState = $this->noDebuggingState; | |||||
if ( $this->nextQueryCachable ) { | |||||
$conn->nextQueryCachable = true; | $conn->nextQueryCachable = true; | ||||
$this->nextQueryCachable = false; | $this->nextQueryCachable = false; | ||||
} | } | ||||
} | |||||
return $conn; | return $conn; | ||||
} | } | ||||
/** | /** | ||||
* Checks if previous query execution raised an error. | * Checks if previous query execution raised an error. | ||||
* | * | ||||
* @return bool | * @return bool | ||||
▲ Show 20 Lines • Show All 107 Lines • ▼ Show 20 Line(s) | |||||
/** | /** | ||||
* Queries db with $sql query supplied and returns rows selected if any, false otherwise. | * 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. | * Optional parameter $key_field allows to set one of the query fields value as key in string array. | ||||
* | * | ||||
* @param string $sql | * @param string $sql | ||||
* @param string $key_field | * @param string $key_field | ||||
* @param bool $no_debug | * @param boolean|null $no_debug | ||||
* @return Array | * @return Array | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function Query($sql, $key_field = null, $no_debug = false) | public function Query($sql, $key_field = null, $no_debug = null) | ||||
{ | { | ||||
$conn =& $this->chooseConnection($sql); | $conn =& $this->chooseConnection($sql); | ||||
return $conn->Query($sql, $key_field, $no_debug); | return $conn->Query($sql, $key_field, $no_debug); | ||||
} | } | ||||
/** | /** | ||||
* Returns iterator to a recordset, produced from running $sql query. | * 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. | * 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. | * Optional parameter $key_field allows to set one of the query fields value as key in string array. | ||||
* | * | ||||
* @param string $sql | * @param string $sql | ||||
* @param string $key_field | * @param string $key_field | ||||
* @param bool $no_debug | * @param boolean|null $no_debug | ||||
* @param string $iterator_class | * @param string $iterator_class | ||||
* @return kMySQLQuery|bool | * @return kMySQLQuery|bool | ||||
* @access public | * @access public | ||||
*/ | */ | ||||
public function GetIterator($sql, $key_field = null, $no_debug = false, $iterator_class = 'kMySQLQuery') | public function GetIterator($sql, $key_field = null, $no_debug = null, $iterator_class = 'kMySQLQuery') | ||||
{ | { | ||||
$conn =& $this->chooseConnection($sql); | $conn =& $this->chooseConnection($sql); | ||||
return $conn->GetIterator($sql, $key_field, $no_debug, $iterator_class); | return $conn->GetIterator($sql, $key_field, $no_debug, $iterator_class); | ||||
} | } | ||||
/** | /** | ||||
* Free memory used to hold recordset handle. | * Free memory used to hold recordset handle. | ||||
▲ Show 20 Lines • Show All 267 Lines • Show Last 20 Lines |