mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-08-07 01:03:31 +02:00
Feature 511 : add support for sqlite database engine
Using session_write_close function when session handler use database because write is called after object destruction. git-svn-id: http://piwigo.org/svn/trunk@4781 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
@@ -70,8 +70,6 @@ function pwg_query($query)
|
||||
{
|
||||
global $conf,$page,$debug,$t2;
|
||||
|
||||
// Log::getInstance()->debug($query);
|
||||
|
||||
$start = get_moment();
|
||||
($result = pg_query($query)) or die($query."\n<br>".pg_last_error());
|
||||
|
||||
@@ -212,9 +210,9 @@ function mass_updates($tablename, $dbfields, $datas, $flags=0)
|
||||
{
|
||||
if (count($datas) == 0)
|
||||
return;
|
||||
// depending on the MySQL version, we use the multi table update or N update queries
|
||||
|
||||
if (count($datas) < 10)
|
||||
{ // MySQL is prior to version 4.0.4, multi table update feature is not available
|
||||
{
|
||||
foreach ($datas as $data)
|
||||
{
|
||||
$query = '
|
||||
@@ -378,61 +376,26 @@ function do_maintenance_all_tables()
|
||||
$all_tables = array();
|
||||
|
||||
// List all tables
|
||||
$query = 'SHOW TABLES LIKE \''.$prefixeTable.'%\'';
|
||||
$result = pwg_query($query);
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
array_push($all_tables, $row[0]);
|
||||
}
|
||||
$query = 'SELECT tablename FROM pg_tables
|
||||
WHERE tablename like \''.$prefixeTable.'%\'';
|
||||
|
||||
// Repair all tables
|
||||
$query = 'REPAIR TABLE '.implode(', ', $all_tables);
|
||||
$mysql_rc = pwg_query($query);
|
||||
|
||||
// Re-Order all tables
|
||||
foreach ($all_tables as $table_name)
|
||||
{
|
||||
$all_primary_key = array();
|
||||
|
||||
$query = 'DESC '.$table_name.';';
|
||||
$result = pwg_query($query);
|
||||
while ($row = pwg_db_fetch_assoc($result))
|
||||
{
|
||||
if ($row['Key'] == 'PRI')
|
||||
{
|
||||
array_push($all_primary_key, $row['Field']);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($all_primary_key) != 0)
|
||||
{
|
||||
$query = 'ALTER TABLE '.$table_name.' ORDER BY '.implode(', ', $all_primary_key).';';
|
||||
$mysql_rc = $mysql_rc && pwg_query($query);
|
||||
}
|
||||
}
|
||||
$all_tables = array_from_query($query, 'tablename');
|
||||
|
||||
// Optimize all tables
|
||||
$query = 'OPTIMIZE TABLE '.implode(', ', $all_tables);
|
||||
$mysql_rc = $mysql_rc && pwg_query($query);
|
||||
if ($mysql_rc)
|
||||
foreach ($all_tables as $table)
|
||||
{
|
||||
array_push(
|
||||
$page['infos'],
|
||||
l10n('Optimizations completed')
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push(
|
||||
$page['errors'],
|
||||
l10n('Optimizations errors')
|
||||
);
|
||||
$query = 'VACUUM FULL '.$table;
|
||||
pwg_query($query);
|
||||
}
|
||||
array_push($page['infos'],
|
||||
l10n('Optimizations completed')
|
||||
);
|
||||
}
|
||||
|
||||
function pwg_db_concat_ws($string, $separaor)
|
||||
function pwg_db_concat_ws($array, $separator)
|
||||
{
|
||||
return 'ARRAY_TO_STRING(ARRAY['.$string.'],\''.$separaor.'\')';
|
||||
$string = implode($array, ',');
|
||||
return 'ARRAY_TO_STRING(ARRAY['.$string.'],\''.$separator.'\')';
|
||||
}
|
||||
|
||||
function pwg_db_cast_to_text($string)
|
||||
@@ -449,7 +412,6 @@ function pwg_db_cast_to_text($string)
|
||||
function get_enums($table, $field)
|
||||
{
|
||||
$typname = preg_replace('/'.$GLOBALS['prefixeTable'].'/', '', $table);
|
||||
Log::getInstance()->debug($typname);
|
||||
$typname .= '_' . $field;
|
||||
|
||||
$query = 'SELECT
|
||||
|
||||
Reference in New Issue
Block a user