Changeset 5424 for extensions/grum_plugins_classes-2/tables.class.inc.php
- Timestamp:
- Mar 28, 2010, 7:17:31 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/grum_plugins_classes-2/tables.class.inc.php
r3395 r5424 1 <?php 1 <?php 2 2 3 3 /* ----------------------------------------------------------------------------- 4 4 class name: manage_tables 5 class version: 1. 46 date: 20 08-12-285 class version: 1.5 6 date: 2010-03-28 7 7 ------------------------------------------------------------------------------ 8 author: grum at grum.dnsalias.com8 author: grum at piwigo.org 9 9 << May the Little SpaceFrog be with you >> 10 10 ------------------------------------------------------------------------------ 11 11 12 12 this class provides base functions to manage tables while plugin installation 13 13 - constructor manage_tables($tables) … … 31 31 + $resultbooelan option for return 32 32 + add multi_queries($queries) function 33 + add import($filename) function 33 + add import($filename) function 34 34 v1.4 - 2009-03-01 + PHP5 migration (use of public/protected/private) 35 35 + export => DROP TABLE IF EXISTS 36 36 + import => if DROP TABLE without IF EXISTS, add IF EXISTS 37 v1.5 - 2010-03-28 + Uses piwigo pwg_db_* functions instead of mysql_* functions 37 38 38 39 -------------------------------------------------------------------------- */ … … 46 47 $this->tables = $tables; 47 48 } 48 49 /* 49 50 /* 50 51 create tables 51 52 $tables_def is an array of SQL CREATE queries 52 53 53 return true if everything is ok, otherwise tablename 54 return true if everything is ok, otherwise tablename 54 55 */ 55 56 public function create_tables($tables_def) … … 71 72 } 72 73 73 /* update tables definition 74 /* update tables definition 74 75 $tables_alteration : array of arrays 75 76 example : … … 81 82 "attribute2" => " ADD COLUMN `attribute2` text null default ''")); 82 83 83 return true if no error, otherwise return table.fields of error 84 return true if no error, otherwise return table.fields of error 84 85 */ 85 86 public function update_tables_fields($tables_alteration) … … 98 99 { 99 100 $columns=array(); 100 while($row= mysql_fetch_assoc($result))101 { 102 array_push($columns, $row['Field']); 101 while($row=pwg_db_fetch_assoc($result)) 102 { 103 array_push($columns, $row['Field']); 103 104 } 104 105 … … 121 122 122 123 123 /* 124 /* 124 125 delete tables listed in $this->tables_list 125 126 */ … … 170 171 if($result) 171 172 { 172 while($row= mysql_fetch_row($result))173 while($row=pwg_db_fetch_row($result)) 173 174 { 174 175 if(isset($list[$row[0]])) … … 207 208 if empty, assume that all tables have to be exported 208 209 $infos : additional info written in exported file (as comment) 209 $resultboolean : if true, result is true/false ; 210 $resultboolean : if true, result is true/false ; 210 211 if false, if result, return a string with nfo about export 211 212 */ … … 295 296 if($result) 296 297 { 297 while($row= mysql_fetch_row($result))298 while($row=pwg_db_fetch_row($result)) 298 299 { 299 300 $text.=sprintf("%s; -- EOQ\n", $row[1]); … … 316 317 { 317 318 $tmp=array(); 318 while($row= mysql_fetch_row($result))319 while($row=pwg_db_fetch_row($result)) 319 320 { 320 321 $tmp[]=$row[0]; … … 323 324 $colnames='('.implode(',', $tmp).')'; 324 325 } 325 326 326 327 $sql='SELECT * FROM '.$this->tables[$key]; 327 328 $result=pwg_query($sql); 328 329 if($result) 329 330 { 330 while($row= mysql_fetch_row($result))331 while($row=pwg_db_fetch_row($result)) 331 332 { 332 333 foreach($row as $key2 => $val2) … … 403 404 execute multiple query 404 405 each query have to be separated by a "-- EOQ\n" 405 406 406 407 $queries : sql queries 407 408 */
Note: See TracChangeset
for help on using the changeset viewer.