Skip to content
Extraits de code Groupes Projets
Valider f882401d rédigé par mattpiwik's avatar mattpiwik
Parcourir les fichiers

more debug information to debug build

git-svn-id: http://dev.piwik.org/svn/trunk@7796 59fd770c-687e-43c8-a1e3-f5a4ff64c105
parent 048dad0c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
<?php <?php
/** /**
* Piwik - Open source web analytics * Piwik - Open source web analytics
* *
* @link http://piwik.org * @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
* @version $Id$ * @version $Id$
* *
* @category Piwik * @category Piwik
* @package PluginsFunctions * @package PluginsFunctions
*/ */
...@@ -25,12 +25,10 @@ class Piwik_Sql ...@@ -25,12 +25,10 @@ class Piwik_Sql
static private function getDb() static private function getDb()
{ {
$db = null; $db = null;
if(!empty($GLOBALS['PIWIK_TRACKER_MODE'])) if (!empty($GLOBALS['PIWIK_TRACKER_MODE'])) {
{
$db = Piwik_Tracker::getDatabase(); $db = Piwik_Tracker::getDatabase();
} }
if($db === null) if ($db === null) {
{
$db = Zend_Registry::get('db'); $db = Zend_Registry::get('db');
} }
return $db; return $db;
...@@ -46,7 +44,11 @@ class Piwik_Sql ...@@ -46,7 +44,11 @@ class Piwik_Sql
*/ */
static public function exec($sql) static public function exec($sql)
{ {
$profiler = Zend_Registry::get('db')->getProfiler(); $db = Zend_Registry::get('db');
if (empty($db)) {
debug_print_backtrace();
}
$profiler = $db->getProfiler();
$q = $profiler->queryStart($sql, Zend_Db_Profiler::INSERT); $q = $profiler->queryStart($sql, Zend_Db_Profiler::INSERT);
$return = self::getDb()->exec($sql); $return = self::getDb()->exec($sql);
$profiler->queryEnd($q); $profiler->queryEnd($q);
...@@ -103,10 +105,10 @@ class Piwik_Sql ...@@ -103,10 +105,10 @@ class Piwik_Sql
{ {
return self::getDb()->fetchOne($sql, $parameters); return self::getDb()->fetchOne($sql, $parameters);
} }
/** /**
* Fetches result from the database query as an array of associative arrays. * Fetches result from the database query as an array of associative arrays.
* *
* @param string $sql SQL query * @param string $sql SQL query
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return array * @return array
...@@ -126,19 +128,18 @@ class Piwik_Sql ...@@ -126,19 +128,18 @@ class Piwik_Sql
* @param array $parameters Parameters to bind in the query. * @param array $parameters Parameters to bind in the query.
* @return int The total number of rows deleted. * @return int The total number of rows deleted.
*/ */
static public function deleteAllRows( $table, $where, $maxRowsPerQuery = 100000, $parameters = array() ) static public function deleteAllRows($table, $where, $maxRowsPerQuery = 100000, $parameters = array())
{ {
$sql = "DELETE FROM $table $where LIMIT ".(int)$maxRowsPerQuery; $sql = "DELETE FROM $table $where LIMIT " . (int)$maxRowsPerQuery;
// delete rows w/ a limit // delete rows w/ a limit
$totalRowsDeleted = 0; $totalRowsDeleted = 0;
do do {
{
$rowsDeleted = self::query($sql, $parameters)->rowCount(); $rowsDeleted = self::query($sql, $parameters)->rowCount();
$totalRowsDeleted += $rowsDeleted; $totalRowsDeleted += $rowsDeleted;
} while ($rowsDeleted >= $maxRowsPerQuery); } while ($rowsDeleted >= $maxRowsPerQuery);
return $totalRowsDeleted; return $totalRowsDeleted;
} }
...@@ -148,40 +149,36 @@ class Piwik_Sql ...@@ -148,40 +149,36 @@ class Piwik_Sql
* @param string|array $tables The name of the table to optimize or an array of tables to optimize. * @param string|array $tables The name of the table to optimize or an array of tables to optimize.
* @return Zend_Db_Statement * @return Zend_Db_Statement
*/ */
static public function optimizeTables( $tables ) static public function optimizeTables($tables)
{ {
$optimize = Piwik_Config::getInstance()->General['enable_sql_optimize_queries']; $optimize = Piwik_Config::getInstance()->General['enable_sql_optimize_queries'];
if(empty($optimize)) { if (empty($optimize)) {
return; return;
} }
if(empty($tables)) if (empty($tables)) {
{
return false; return false;
} }
if (!is_array($tables)) if (!is_array($tables)) {
{
$tables = array($tables); $tables = array($tables);
} }
// filter out all InnoDB tables // filter out all InnoDB tables
$nonInnoDbTables = array(); $nonInnoDbTables = array();
foreach (Piwik_FetchAll("SHOW TABLE STATUS") as $row) foreach (Piwik_FetchAll("SHOW TABLE STATUS") as $row) {
{
if (strtolower($row['Engine']) != 'innodb' if (strtolower($row['Engine']) != 'innodb'
&& in_array($row['Name'], $tables)) && in_array($row['Name'], $tables)
{ ) {
$nonInnoDbTables[] = $row['Name']; $nonInnoDbTables[] = $row['Name'];
} }
} }
if (empty($nonInnoDbTables)) if (empty($nonInnoDbTables)) {
{
return false; return false;
} }
// optimize the tables // optimize the tables
return self::query("OPTIMIZE TABLE ".implode(',', $nonInnoDbTables)); return self::query("OPTIMIZE TABLE " . implode(',', $nonInnoDbTables));
} }
/** /**
...@@ -190,14 +187,13 @@ class Piwik_Sql ...@@ -190,14 +187,13 @@ class Piwik_Sql
* @param string|array $tables The name of the table to drop or an array of table names to drop. * @param string|array $tables The name of the table to drop or an array of table names to drop.
* @return Zend_Db_Statement * @return Zend_Db_Statement
*/ */
static public function dropTables( $tables ) static public function dropTables($tables)
{ {
if (!is_array($tables)) if (!is_array($tables)) {
{
$tables = array($tables); $tables = array($tables);
} }
return self::query("DROP TABLE ".implode(',', $tables)); return self::query("DROP TABLE " . implode(',', $tables));
} }
/** /**
...@@ -207,28 +203,24 @@ class Piwik_Sql ...@@ -207,28 +203,24 @@ class Piwik_Sql
* @param string|array $tablesToWrite The table or tables to obtain 'write' locks on. * @param string|array $tablesToWrite The table or tables to obtain 'write' locks on.
* @return Zend_Db_Statement * @return Zend_Db_Statement
*/ */
static public function lockTables( $tablesToRead, $tablesToWrite = array() ) static public function lockTables($tablesToRead, $tablesToWrite = array())
{ {
if (!is_array($tablesToRead)) if (!is_array($tablesToRead)) {
{
$tablesToRead = array($tablesToRead); $tablesToRead = array($tablesToRead);
} }
if (!is_array($tablesToWrite)) if (!is_array($tablesToWrite)) {
{
$tablesToWrite = array($tablesToWrite); $tablesToWrite = array($tablesToWrite);
} }
$lockExprs = array(); $lockExprs = array();
foreach ($tablesToWrite as $table) foreach ($tablesToWrite as $table) {
{ $lockExprs[] = $table . " WRITE";
$lockExprs[] = $table." WRITE";
} }
foreach ($tablesToRead as $table) foreach ($tablesToRead as $table) {
{ $lockExprs[] = $table . " READ";
$lockExprs[] = $table." READ";
} }
return self::exec("LOCK TABLES ".implode(', ', $lockExprs)); return self::exec("LOCK TABLES " . implode(', ', $lockExprs));
} }
/** /**
...@@ -240,11 +232,11 @@ class Piwik_Sql ...@@ -240,11 +232,11 @@ class Piwik_Sql
{ {
return self::exec("UNLOCK TABLES"); return self::exec("UNLOCK TABLES");
} }
/** /**
* Performs a SELECT on a table one chunk at a time and returns the first * Performs a SELECT on a table one chunk at a time and returns the first
* fetched value. * fetched value.
* *
* @param string $sql The SQL to perform. The last two conditions of the WHERE * @param string $sql The SQL to perform. The last two conditions of the WHERE
* expression must be as follows: 'id >= ? AND id < ?' where * expression must be as follows: 'id >= ? AND id < ?' where
* 'id' is the int id of the table. If $step < 0, the condition * 'id' is the int id of the table. If $step < 0, the condition
...@@ -255,30 +247,25 @@ class Piwik_Sql ...@@ -255,30 +247,25 @@ class Piwik_Sql
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return array * @return array
*/ */
static public function segmentedFetchFirst( $sql, $first, $last, $step, $params ) static public function segmentedFetchFirst($sql, $first, $last, $step, $params)
{ {
$result = false; $result = false;
if ($step > 0) if ($step > 0) {
{ for ($i = $first; $result === false && $i <= $last; $i += $step) {
for ($i = $first; $result === false && $i <= $last; $i += $step)
{
$result = self::fetchOne($sql, array_merge($params, array($i, $i + $step))); $result = self::fetchOne($sql, array_merge($params, array($i, $i + $step)));
} }
} } else {
else for ($i = $first; $result === false && $i >= $last; $i += $step) {
{
for ($i = $first; $result === false && $i >= $last; $i += $step)
{
$result = self::fetchOne($sql, array_merge($params, array($i, $i + $step))); $result = self::fetchOne($sql, array_merge($params, array($i, $i + $step)));
} }
} }
return $result; return $result;
} }
/** /**
* Performs a SELECT on a table one chunk at a time and returns an array * Performs a SELECT on a table one chunk at a time and returns an array
* of every fetched value. * of every fetched value.
* *
* @param string $sql The SQL to perform. The last two conditions of the WHERE * @param string $sql The SQL to perform. The last two conditions of the WHERE
* expression must be as follows: 'id >= ? AND id < ?' where * expression must be as follows: 'id >= ? AND id < ?' where
* 'id' is the int id of the table. * 'id' is the int id of the table.
...@@ -288,30 +275,25 @@ class Piwik_Sql ...@@ -288,30 +275,25 @@ class Piwik_Sql
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return array * @return array
*/ */
static public function segmentedFetchOne( $sql, $first, $last, $step, $params ) static public function segmentedFetchOne($sql, $first, $last, $step, $params)
{ {
$result = array(); $result = array();
if ($step > 0) if ($step > 0) {
{ for ($i = $first; $i <= $last; $i += $step) {
for ($i = $first; $i <= $last; $i += $step)
{
$result[] = self::fetchOne($sql, array_merge($params, array($i, $i + $step))); $result[] = self::fetchOne($sql, array_merge($params, array($i, $i + $step)));
} }
} } else {
else for ($i = $first; $i >= $last; $i += $step) {
{
for ($i = $first; $i >= $last; $i += $step)
{
$result[] = self::fetchOne($sql, array_merge($params, array($i, $i + $step))); $result[] = self::fetchOne($sql, array_merge($params, array($i, $i + $step)));
} }
} }
return $result; return $result;
} }
/** /**
* Performs a SELECT on a table one chunk at a time and returns an array * Performs a SELECT on a table one chunk at a time and returns an array
* of every fetched row. * of every fetched row.
* *
* @param string $sql The SQL to perform. The last two conditions of the WHERE * @param string $sql The SQL to perform. The last two conditions of the WHERE
* expression must be as follows: 'id >= ? AND id < ?' where * expression must be as follows: 'id >= ? AND id < ?' where
* 'id' is the int id of the table. * 'id' is the int id of the table.
...@@ -321,31 +303,26 @@ class Piwik_Sql ...@@ -321,31 +303,26 @@ class Piwik_Sql
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return array * @return array
*/ */
static public function segmentedFetchAll( $sql, $first, $last, $step, $params ) static public function segmentedFetchAll($sql, $first, $last, $step, $params)
{ {
$result = array(); $result = array();
if ($step > 0) if ($step > 0) {
{ for ($i = $first; $i <= $last; $i += $step) {
for ($i = $first; $i <= $last; $i += $step)
{
$currentParams = array_merge($params, array($i, $i + $step)); $currentParams = array_merge($params, array($i, $i + $step));
$result = array_merge($result, self::fetchAll($sql, $currentParams)); $result = array_merge($result, self::fetchAll($sql, $currentParams));
} }
} } else {
else for ($i = $first; $i >= $last; $i += $step) {
{
for ($i = $first; $i >= $last; $i += $step)
{
$currentParams = array_merge($params, array($i, $i + $step)); $currentParams = array_merge($params, array($i, $i + $step));
$result = array_merge($result, self::fetchAll($sql, $currentParams)); $result = array_merge($result, self::fetchAll($sql, $currentParams));
} }
} }
return $result; return $result;
} }
/** /**
* Performs a non-SELECT query on a table one chunk at a time. * Performs a non-SELECT query on a table one chunk at a time.
* *
* @param string $sql The SQL to perform. The last two conditions of the WHERE * @param string $sql The SQL to perform. The last two conditions of the WHERE
* expression must be as follows: 'id >= ? AND id < ?' where * expression must be as follows: 'id >= ? AND id < ?' where
* 'id' is the int id of the table. * 'id' is the int id of the table.
...@@ -355,35 +332,30 @@ class Piwik_Sql ...@@ -355,35 +332,30 @@ class Piwik_Sql
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return array * @return array
*/ */
static public function segmentedQuery( $sql, $first, $last, $step, $params ) static public function segmentedQuery($sql, $first, $last, $step, $params)
{ {
if ($step > 0) if ($step > 0) {
{ for ($i = $first; $i <= $last; $i += $step) {
for ($i = $first; $i <= $last; $i += $step)
{
$currentParams = array_merge($params, array($i, $i + $step)); $currentParams = array_merge($params, array($i, $i + $step));
self::query($sql, $currentParams); self::query($sql, $currentParams);
} }
} } else {
else for ($i = $first; $i >= $last; $i += $step) {
{
for ($i = $first; $i >= $last; $i += $step)
{
$currentParams = array_merge($params, array($i, $i + $step)); $currentParams = array_merge($params, array($i, $i + $step));
self::query($sql, $currentParams); self::query($sql, $currentParams);
} }
} }
} }
/** /**
* Attempts to get a named lock. This function uses a timeout of 1s, but will * Attempts to get a named lock. This function uses a timeout of 1s, but will
* retry a set number of time. * retry a set number of time.
* *
* @param string $lockName The lock name. * @param string $lockName The lock name.
* @param int $maxRetries The max number of times to retry. * @param int $maxRetries The max number of times to retry.
* @return bool true if the lock was obtained, false if otherwise. * @return bool true if the lock was obtained, false if otherwise.
*/ */
static public function getDbLock( $lockName, $maxRetries = 30 ) static public function getDbLock($lockName, $maxRetries = 30)
{ {
/* /*
* the server (e.g., shared hosting) may have a low wait timeout * the server (e.g., shared hosting) may have a low wait timeout
...@@ -395,24 +367,22 @@ class Piwik_Sql ...@@ -395,24 +367,22 @@ class Piwik_Sql
$db = Zend_Registry::get('db'); $db = Zend_Registry::get('db');
while ($maxRetries > 0) while ($maxRetries > 0) {
{ if ($db->fetchOne($sql, array($lockName)) == '1') {
if ($db->fetchOne($sql, array($lockName)) == '1')
{
return true; return true;
} }
$maxRetries--; $maxRetries--;
} }
return false; return false;
} }
/** /**
* Releases a named lock. * Releases a named lock.
* *
* @param string $lockName The lock name. * @param string $lockName The lock name.
* @return bool true if the lock was released, false if otherwise. * @return bool true if the lock was released, false if otherwise.
*/ */
static public function releaseDbLock( $lockName ) static public function releaseDbLock($lockName)
{ {
$sql = 'SELECT RELEASE_LOCK(?)'; $sql = 'SELECT RELEASE_LOCK(?)';
...@@ -439,7 +409,7 @@ function Piwik_Exec($sqlQuery) ...@@ -439,7 +409,7 @@ function Piwik_Exec($sqlQuery)
/** /**
* Executes a SQL query on the DB and returns the Zend_Db_Statement object * Executes a SQL query on the DB and returns the Zend_Db_Statement object
* If you want to fetch data from the DB you should use the function Piwik_FetchAll() * If you want to fetch data from the DB you should use the function Piwik_FetchAll()
* *
* See also http://framework.zend.com/manual/en/zend.db.statement.html * See also http://framework.zend.com/manual/en/zend.db.statement.html
* *
* @see Piwik_Sql::query * @see Piwik_Sql::query
...@@ -462,7 +432,7 @@ function Piwik_Query($sqlQuery, $parameters = array()) ...@@ -462,7 +432,7 @@ function Piwik_Query($sqlQuery, $parameters = array())
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return array (one row in the array per row fetched in the DB) * @return array (one row in the array per row fetched in the DB)
*/ */
function Piwik_FetchAll( $sqlQuery, $parameters = array()) function Piwik_FetchAll($sqlQuery, $parameters = array())
{ {
return Piwik_Sql::fetchAll($sqlQuery, $parameters); return Piwik_Sql::fetchAll($sqlQuery, $parameters);
} }
...@@ -490,19 +460,19 @@ function Piwik_FetchRow($sqlQuery, $parameters = array()) ...@@ -490,19 +460,19 @@ function Piwik_FetchRow($sqlQuery, $parameters = array())
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return string * @return string
*/ */
function Piwik_FetchOne( $sqlQuery, $parameters = array()) function Piwik_FetchOne($sqlQuery, $parameters = array())
{ {
return Piwik_Sql::fetchOne($sqlQuery, $parameters); return Piwik_Sql::fetchOne($sqlQuery, $parameters);
} }
/** /**
* Fetches result from the database query as an array of associative arrays. * Fetches result from the database query as an array of associative arrays.
* *
* @param string $sqlQuery * @param string $sqlQuery
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return array * @return array
*/ */
function Piwik_FetchAssoc( $sqlQuery, $parameters = array() ) function Piwik_FetchAssoc($sqlQuery, $parameters = array())
{ {
return Piwik_Sql::fetchAssoc($sqlQuery, $parameters); return Piwik_Sql::fetchAssoc($sqlQuery, $parameters);
} }
...@@ -519,7 +489,7 @@ function Piwik_FetchAssoc( $sqlQuery, $parameters = array() ) ...@@ -519,7 +489,7 @@ function Piwik_FetchAssoc( $sqlQuery, $parameters = array() )
* @param array $parameters Parameters to bind in the query. * @param array $parameters Parameters to bind in the query.
* @return int The total number of rows deleted. * @return int The total number of rows deleted.
*/ */
function Piwik_DeleteAllRows( $table, $where, $maxRowsPerQuery, $parameters = array() ) function Piwik_DeleteAllRows($table, $where, $maxRowsPerQuery, $parameters = array())
{ {
return Piwik_Sql::deleteAllRows($table, $where, $maxRowsPerQuery, $parameters); return Piwik_Sql::deleteAllRows($table, $where, $maxRowsPerQuery, $parameters);
} }
...@@ -532,7 +502,7 @@ function Piwik_DeleteAllRows( $table, $where, $maxRowsPerQuery, $parameters = ar ...@@ -532,7 +502,7 @@ function Piwik_DeleteAllRows( $table, $where, $maxRowsPerQuery, $parameters = ar
* @param string|array $tables The name of the table to optimize or an array of tables to optimize. * @param string|array $tables The name of the table to optimize or an array of tables to optimize.
* @return Zend_Db_Statement * @return Zend_Db_Statement
*/ */
function Piwik_OptimizeTables( $tables ) function Piwik_OptimizeTables($tables)
{ {
return Piwik_Sql::optimizeTables($tables); return Piwik_Sql::optimizeTables($tables);
} }
...@@ -545,7 +515,7 @@ function Piwik_OptimizeTables( $tables ) ...@@ -545,7 +515,7 @@ function Piwik_OptimizeTables( $tables )
* @param string|array $tables The name of the table to drop or an array of table names to drop. * @param string|array $tables The name of the table to drop or an array of table names to drop.
* @return Zend_Db_Statement * @return Zend_Db_Statement
*/ */
function Piwik_DropTables( $tables ) function Piwik_DropTables($tables)
{ {
return Piwik_Sql::dropTables($tables); return Piwik_Sql::dropTables($tables);
} }
...@@ -559,7 +529,7 @@ function Piwik_DropTables( $tables ) ...@@ -559,7 +529,7 @@ function Piwik_DropTables( $tables )
* @param string|array $tablesToWrite The table or tables to obtain 'write' locks on. * @param string|array $tablesToWrite The table or tables to obtain 'write' locks on.
* @return Zend_Db_Statement * @return Zend_Db_Statement
*/ */
function Piwik_LockTables( $tablesToRead, $tablesToWrite = array() ) function Piwik_LockTables($tablesToRead, $tablesToWrite = array())
{ {
return Piwik_Sql::lockTables($tablesToRead, $tablesToWrite); return Piwik_Sql::lockTables($tablesToRead, $tablesToWrite);
} }
...@@ -579,14 +549,14 @@ function Piwik_UnlockAllTables() ...@@ -579,14 +549,14 @@ function Piwik_UnlockAllTables()
/** /**
* Performs a SELECT on a table one chunk at a time and returns the first * Performs a SELECT on a table one chunk at a time and returns the first
* fetched value. * fetched value.
* *
* This function will break up a SELECT into several smaller SELECTs and * This function will break up a SELECT into several smaller SELECTs and
* should be used when performing a SELECT that can take a long time to finish. * should be used when performing a SELECT that can take a long time to finish.
* Using several smaller SELECTs will ensure that the table will not be locked * Using several smaller SELECTs will ensure that the table will not be locked
* for too long. * for too long.
* *
* @see Piwik_Sql::segmentedFetchFirst * @see Piwik_Sql::segmentedFetchFirst
* *
* @param string $sql The SQL to perform. The last two conditions of the WHERE * @param string $sql The SQL to perform. The last two conditions of the WHERE
* expression must be as follows: 'id >= ? AND id < ?' where * expression must be as follows: 'id >= ? AND id < ?' where
* 'id' is the int id of the table. * 'id' is the int id of the table.
...@@ -596,7 +566,7 @@ function Piwik_UnlockAllTables() ...@@ -596,7 +566,7 @@ function Piwik_UnlockAllTables()
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return string * @return string
*/ */
function Piwik_SegmentedFetchFirst( $sql, $first, $last, $step, $params = array() ) function Piwik_SegmentedFetchFirst($sql, $first, $last, $step, $params = array())
{ {
return Piwik_Sql::segmentedFetchFirst($sql, $first, $last, $step, $params); return Piwik_Sql::segmentedFetchFirst($sql, $first, $last, $step, $params);
} }
...@@ -604,14 +574,14 @@ function Piwik_SegmentedFetchFirst( $sql, $first, $last, $step, $params = array( ...@@ -604,14 +574,14 @@ function Piwik_SegmentedFetchFirst( $sql, $first, $last, $step, $params = array(
/** /**
* Performs a SELECT on a table one chunk at a time and returns an array * Performs a SELECT on a table one chunk at a time and returns an array
* of every fetched value. * of every fetched value.
* *
* This function will break up a SELECT into several smaller SELECTs and * This function will break up a SELECT into several smaller SELECTs and
* should be used when performing a SELECT that can take a long time to finish. * should be used when performing a SELECT that can take a long time to finish.
* Using several smaller SELECTs will ensure that the table will not be locked * Using several smaller SELECTs will ensure that the table will not be locked
* for too long. * for too long.
* *
* @see Piwik_Sql::segmentedFetchFirst * @see Piwik_Sql::segmentedFetchFirst
* *
* @param string $sql The SQL to perform. The last two conditions of the WHERE * @param string $sql The SQL to perform. The last two conditions of the WHERE
* expression must be as follows: 'id >= ? AND id < ?' where * expression must be as follows: 'id >= ? AND id < ?' where
* 'id' is the int id of the table. * 'id' is the int id of the table.
...@@ -621,7 +591,7 @@ function Piwik_SegmentedFetchFirst( $sql, $first, $last, $step, $params = array( ...@@ -621,7 +591,7 @@ function Piwik_SegmentedFetchFirst( $sql, $first, $last, $step, $params = array(
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return array * @return array
*/ */
function Piwik_SegmentedFetchOne( $sql, $first, $last, $step, $params = array() ) function Piwik_SegmentedFetchOne($sql, $first, $last, $step, $params = array())
{ {
return Piwik_Sql::segmentedFetchOne($sql, $first, $last, $step, $params); return Piwik_Sql::segmentedFetchOne($sql, $first, $last, $step, $params);
} }
...@@ -629,14 +599,14 @@ function Piwik_SegmentedFetchOne( $sql, $first, $last, $step, $params = array() ...@@ -629,14 +599,14 @@ function Piwik_SegmentedFetchOne( $sql, $first, $last, $step, $params = array()
/** /**
* Performs a SELECT on a table one chunk at a time and returns an array * Performs a SELECT on a table one chunk at a time and returns an array
* of every fetched row. * of every fetched row.
* *
* This function will break up a SELECT into several smaller SELECTs and * This function will break up a SELECT into several smaller SELECTs and
* should be used when performing a SELECT that can take a long time to finish. * should be used when performing a SELECT that can take a long time to finish.
* Using several smaller SELECTs will ensure that the table will not be locked * Using several smaller SELECTs will ensure that the table will not be locked
* for too long. * for too long.
* *
* @see Piwik_Sql::segmentedFetchFirst * @see Piwik_Sql::segmentedFetchFirst
* *
* @param string $sql The SQL to perform. The last two conditions of the WHERE * @param string $sql The SQL to perform. The last two conditions of the WHERE
* expression must be as follows: 'id >= ? AND id < ?' where * expression must be as follows: 'id >= ? AND id < ?' where
* 'id' is the int id of the table. * 'id' is the int id of the table.
...@@ -646,7 +616,7 @@ function Piwik_SegmentedFetchOne( $sql, $first, $last, $step, $params = array() ...@@ -646,7 +616,7 @@ function Piwik_SegmentedFetchOne( $sql, $first, $last, $step, $params = array()
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return array * @return array
*/ */
function Piwik_SegmentedFetchAll( $sql, $first, $last, $step, $params = array() ) function Piwik_SegmentedFetchAll($sql, $first, $last, $step, $params = array())
{ {
return Piwik_Sql::segmentedFetchAll($sql, $first, $last, $step, $params); return Piwik_Sql::segmentedFetchAll($sql, $first, $last, $step, $params);
} }
...@@ -654,14 +624,14 @@ function Piwik_SegmentedFetchAll( $sql, $first, $last, $step, $params = array() ...@@ -654,14 +624,14 @@ function Piwik_SegmentedFetchAll( $sql, $first, $last, $step, $params = array()
/** /**
* Performs a query on a table one chunk at a time and returns an array of * Performs a query on a table one chunk at a time and returns an array of
* every fetched row. * every fetched row.
* *
* This function will break up a non-SELECT query (like an INSERT, UPDATE, or * This function will break up a non-SELECT query (like an INSERT, UPDATE, or
* DELETE) into smaller queries and should be used when performing an operation * DELETE) into smaller queries and should be used when performing an operation
* that can take a long time to finish. Using several small queries will ensure * that can take a long time to finish. Using several small queries will ensure
* that the table will not be locked for too long. * that the table will not be locked for too long.
* *
* @see Piwik_Sql::segmentedQuery * @see Piwik_Sql::segmentedQuery
* *
* @param string $sql The SQL to perform. The last two conditions of the WHERE * @param string $sql The SQL to perform. The last two conditions of the WHERE
* expression must be as follows: 'id >= ? AND id < ?' where * expression must be as follows: 'id >= ? AND id < ?' where
* 'id' is the int id of the table. * 'id' is the int id of the table.
...@@ -671,7 +641,7 @@ function Piwik_SegmentedFetchAll( $sql, $first, $last, $step, $params = array() ...@@ -671,7 +641,7 @@ function Piwik_SegmentedFetchAll( $sql, $first, $last, $step, $params = array()
* @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2) * @param array $parameters Parameters to bind in the query, array( param1 => value1, param2 => value2)
* @return array * @return array
*/ */
function Piwik_SegmentedQuery( $sql, $first, $last, $step, $params = array() ) function Piwik_SegmentedQuery($sql, $first, $last, $step, $params = array())
{ {
return Piwik_Sql::segmentedQuery($sql, $first, $last, $step, $params); return Piwik_Sql::segmentedQuery($sql, $first, $last, $step, $params);
} }
...@@ -679,27 +649,27 @@ function Piwik_SegmentedQuery( $sql, $first, $last, $step, $params = array() ) ...@@ -679,27 +649,27 @@ function Piwik_SegmentedQuery( $sql, $first, $last, $step, $params = array() )
/** /**
* Attempts to get a named lock. This function uses a timeout of 1s, but will * Attempts to get a named lock. This function uses a timeout of 1s, but will
* retry a set number of time. * retry a set number of time.
* *
* @see Piwik_Sql::getDbLock * @see Piwik_Sql::getDbLock
* *
* @param string $lockName The lock name. * @param string $lockName The lock name.
* @param int $maxRetries The max number of times to retry. * @param int $maxRetries The max number of times to retry.
* @return bool true if the lock was obtained, false if otherwise. * @return bool true if the lock was obtained, false if otherwise.
*/ */
function Piwik_GetDbLock( $lockName, $maxRetries = 30 ) function Piwik_GetDbLock($lockName, $maxRetries = 30)
{ {
return Piwik_Sql::getDbLock($lockName, $maxRetries); return Piwik_Sql::getDbLock($lockName, $maxRetries);
} }
/** /**
* Releases a named lock. * Releases a named lock.
* *
* @see Piwik_Sql::releaseDbLock * @see Piwik_Sql::releaseDbLock
* *
* @param string $lockName The lock name. * @param string $lockName The lock name.
* @return bool true if the lock was released, false if otherwise. * @return bool true if the lock was released, false if otherwise.
*/ */
function Piwik_ReleaseDbLock( $lockName ) function Piwik_ReleaseDbLock($lockName)
{ {
return Piwik_Sql::releaseDbLock($lockName); return Piwik_Sql::releaseDbLock($lockName);
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter