Fix some sql issues :

- permalink that use if() syntax
- add tables themes for other database engines that mysql

git-svn-id: http://piwigo.org/svn/trunk@5192 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
nikrou 2010-03-19 19:39:15 +00:00
parent 6b296b293d
commit 4c461f36b1
6 changed files with 51 additions and 6 deletions

View file

@ -98,8 +98,8 @@ elseif ( isset($_GET['delete_permanent']) and !is_adviser() )
DELETE FROM '.OLD_PERMALINKS_TABLE.'
WHERE permalink="'.$_GET['delete_permanent'].'"
LIMIT 1';
pwg_query($query);
if (pwg_db_affected_rows()==0)
$result = pwg_query($query);
if (pwg_db_changes($result)==0)
array_push($page['errors'], l10n('Cannot delete the old permalink !'));
}
@ -108,8 +108,8 @@ $template->set_filename('permalinks', 'permalinks.tpl' );
$query = '
SELECT
id,
'.pwg_db_concat(array('id', '\' - \'', 'name', 'IF(permalink IS NULL, \'\', \' √\')')).' AS name,
id, permalink,
'.pwg_db_concat(array('id', '\' - \'', 'name')).' AS name,
uppercats, global_rank
FROM '.CATEGORIES_TABLE;

View file

@ -124,7 +124,7 @@ SELECT IF(MAX('.$column.')+1 IS NULL, 1, MAX('.$column.')+1)
function pwg_db_changes($result)
{
return mysql_affected_rows($result);
return mysql_affected_rows();
}
function pwg_db_num_rows($result)
@ -461,7 +461,7 @@ function do_maintenance_all_tables()
function pwg_db_concat($array)
{
$string = implode($array, ',');
return 'CONCAT(\''. $string.'\')';
return 'CONCAT('. $string.')';
}
function pwg_db_concat_ws($array, $separator)

View file

@ -311,6 +311,10 @@ function display_select_categories($categories,
$tpl_cats = array();
foreach ($categories as $category)
{
if (!empty($category['permalink']))
{
$category['name'] .= ' √';
}
if ($fullname)
{
$option = get_cat_display_name_cache($category['uppercats'],

View file

@ -340,6 +340,19 @@ CREATE TABLE piwigo_tags
CREATE INDEX "tags_i1" ON "piwigo_tags" ("url_name");
-----------------------------------------------------------------------------
-- piwigo_themes
-----------------------------------------------------------------------------
DROP TABLE IF EXISTS "piwigo_themes" CASCADE;
CREATE TABLE "piwigo_themes"
(
"id" varchar(64) default '' NOT NULL,
"version" varchar(64) NOT NULL default '0',
"name" varchar(64) default NULL,
PRIMARY KEY ("id")
);
-----------------------------------------------------------------------------
-- piwigo_upgrade
-----------------------------------------------------------------------------

View file

@ -414,6 +414,21 @@ COMMENT ON TABLE "piwigo_tags" IS '';
SET search_path TO public;
CREATE INDEX "tags_i1" ON "piwigo_tags" ("url_name");
-----------------------------------------------------------------------------
-- piwigo_themes
-----------------------------------------------------------------------------
DROP TABLE IF EXISTS "piwigo_themes" CASCADE;
CREATE TABLE "piwigo_themes"
(
"id" varchar(64) default '' NOT NULL,
"version" varchar(64) NOT NULL default '0',
"name" varchar(64) default NULL,
PRIMARY KEY ("id")
);
COMMENT ON TABLE "piwigo_themes" IS '';
-----------------------------------------------------------------------------
-- piwigo_upgrade
-----------------------------------------------------------------------------

View file

@ -340,6 +340,19 @@ CREATE TABLE piwigo_tags
CREATE INDEX "tags_i1" ON "piwigo_tags" ("url_name");
-----------------------------------------------------------------------------
-- piwigo_themes
-----------------------------------------------------------------------------
DROP TABLE IF EXISTS "piwigo_themes" CASCADE;
CREATE TABLE "piwigo_themes"
(
"id" varchar(64) default '' NOT NULL,
"version" varchar(64) NOT NULL default '0',
"name" varchar(64) default NULL,
PRIMARY KEY ("id")
);
-----------------------------------------------------------------------------
-- piwigo_upgrade
-----------------------------------------------------------------------------