aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/database.php
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2013-02-04 20:37:25 -0500
committerCash Costello <cash.costello@gmail.com>2013-02-09 07:47:28 -0500
commit85e4c16f39a8b00b229644bcd175663541dfd51a (patch)
tree49a503ec7eebe24f19025fe5ac0c890857cf86cf /engine/lib/database.php
parent2cd87bb4ecf6df7b3aea9189cf1933ac3a78038c (diff)
downloadelgg-85e4c16f39a8b00b229644bcd175663541dfd51a.tar.gz
elgg-85e4c16f39a8b00b229644bcd175663541dfd51a.tar.bz2
Doc fixes and inline type hints for variables (big static analysis cleanup)
Diffstat (limited to 'engine/lib/database.php')
-rw-r--r--engine/lib/database.php22
1 files changed, 14 insertions, 8 deletions
diff --git a/engine/lib/database.php b/engine/lib/database.php
index 7d90b30b8..18c30cb8e 100644
--- a/engine/lib/database.php
+++ b/engine/lib/database.php
@@ -17,7 +17,9 @@
* $DB_QUERY_CACHE[$query] => array(result1, result2, ... resultN)
* </code>
*
- * @global array $DB_QUERY_CACHE
+ * @warning be array this var may be an array or ElggStaticVariableCache depending on when called :(
+ *
+ * @global ElggStaticVariableCache|array $DB_QUERY_CACHE
*/
global $DB_QUERY_CACHE;
$DB_QUERY_CACHE = array();
@@ -48,7 +50,7 @@ $DB_DELAYED_QUERIES = array();
* Each database link created with establish_db_link($name) is stored in
* $dblink as $dblink[$name] => resource. Use get_db_link($name) to retrieve it.
*
- * @global array $dblink
+ * @global resource[] $dblink
*/
global $dblink;
$dblink = array();
@@ -72,6 +74,7 @@ $dbcalls = 0;
* resource. eg "read", "write", or "readwrite".
*
* @return void
+ * @throws DatabaseException
* @access private
*/
function establish_db_link($dblinkname = "readwrite") {
@@ -197,7 +200,7 @@ function db_delayedexecution_shutdown_hook() {
*
* @param string $dblinktype The type of link we want: "read", "write" or "readwrite".
*
- * @return object Database link
+ * @return resource Database link
* @access private
*/
function get_db_link($dblinktype) {
@@ -216,7 +219,7 @@ function get_db_link($dblinktype) {
/**
* Execute an EXPLAIN for $query.
*
- * @param str $query The query to explain
+ * @param string $query The query to explain
* @param mixed $link The database link resource to user.
*
* @return mixed An object of the query's result, or FALSE
@@ -240,9 +243,9 @@ function explain_query($query, $link) {
* {@link $dbcalls} is incremented and the query is saved into the {@link $DB_QUERY_CACHE}.
*
* @param string $query The query
- * @param link $dblink The DB link
+ * @param resource $dblink The DB link
*
- * @return The result of mysql_query()
+ * @return resource result of mysql_query()
* @throws DatabaseException
* @access private
*/
@@ -275,7 +278,7 @@ function execute_query($query, $dblink) {
* the raw result from {@link mysql_query()}.
*
* @param string $query The query to execute
- * @param resource $dblink The database link to use or the link type (read | write)
+ * @param resource|string $dblink The database link to use or the link type (read | write)
* @param string $handler A callback function to pass the results array to
*
* @return true
@@ -410,7 +413,7 @@ function elgg_query_runner($query, $callback = null, $single = false) {
// test for callback once instead of on each iteration.
// @todo check profiling to see if this needs to be broken out into
- // explicit cases instead of checking in the interation.
+ // explicit cases instead of checking in the iteration.
$is_callable = is_callable($callback);
while ($row = mysql_fetch_object($result)) {
if ($is_callable) {
@@ -459,6 +462,7 @@ function insert_data($query) {
// Invalidate query cache
if ($DB_QUERY_CACHE) {
+ /* @var ElggStaticVariableCache $DB_QUERY_CACHE */
$DB_QUERY_CACHE->clear();
}
@@ -490,6 +494,7 @@ function update_data($query) {
// Invalidate query cache
if ($DB_QUERY_CACHE) {
+ /* @var ElggStaticVariableCache $DB_QUERY_CACHE */
$DB_QUERY_CACHE->clear();
elgg_log("Query cache invalidated", 'NOTICE');
}
@@ -520,6 +525,7 @@ function delete_data($query) {
// Invalidate query cache
if ($DB_QUERY_CACHE) {
+ /* @var ElggStaticVariableCache $DB_QUERY_CACHE */
$DB_QUERY_CACHE->clear();
elgg_log("Query cache invalidated", 'NOTICE');
}