source: trunk/install/db/101-database.php @ 11398

Last change on this file since 11398 was 10341, checked in by mistic100, 14 years ago

bug:2224 change nb_image_page into smallint(3)

File size: 2.4 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2011 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die('Hacking attempt!');
27}
28
29$upgrade_description = 'merge nb_line_page and nb_image_line into nb_image_page';
30
31// add column
32if ('mysql' == $conf['dblayer'])
33{
34  pwg_query('
35    ALTER TABLE '.USER_INFOS_TABLE.'
36      ADD COLUMN `nb_image_page` smallint(3) unsigned NOT NULL default \'15\'
37  ;');
38}
39else if (in_array($conf['dblayer'], array('pgsql', 'sqlite', 'pdo-sqlite')))
40{
41  pwg_query('
42    ALTER TABLE '.USER_INFOS_TABLE.'
43      ADD COLUMN "nb_image_page" INTEGER default 15 NOT NULL
44  ;');
45}
46
47// merge datas
48pwg_query('
49  UPDATE '.USER_INFOS_TABLE.'
50  SET nb_image_page = nb_line_page*nb_image_line
51;');
52
53// delete old columns
54pwg_query('
55  ALTER TABLE '.USER_INFOS_TABLE.'
56    DROP `nb_line_page`,
57    DROP `nb_image_line`
58;');
59
60echo
61"\n"
62. $upgrade_description
63."\n"
64;
65?>
Note: See TracBrowser for help on using the repository browser.