11<?php
2+ $ db = ConnectionManager::getDataSource ('default ' );
23// 0.3.0
34function switch_table_name ($ old_table , $ new_table ) {
45
5- global $ db ;
6+ $ db = ConnectionManager:: getDataSource ( ' default ' ) ;
67
78 $ execute = true ;
89
@@ -11,7 +12,7 @@ function switch_table_name($old_table, $new_table) {
1112 } catch (Exception $ e ) {
1213 $ execute = false ;
1314 }
14- if (isset ($ verif ) || empty ($ verif )) {
15+ if (! isset ($ verif ) || empty ($ verif )) {
1516 $ execute = false ;
1617 }
1718
@@ -24,7 +25,7 @@ function switch_table_name($old_table, $new_table) {
2425}
2526function add_column ($ table , $ name , $ sql ) {
2627
27- global $ db ;
28+ $ db = ConnectionManager:: getDataSource ( ' default ' ) ;
2829
2930 $ verif = $ db ->query ('SHOW COLUMNS FROM ' .$ table .'; ' );
3031 $ execute = true ;
@@ -40,7 +41,7 @@ function add_column($table, $name, $sql) {
4041}
4142function remove_column ($ table , $ name ) {
4243
43- global $ db ;
44+ $ db = ConnectionManager:: getDataSource ( ' default ' ) ;
4445
4546 $ verif = $ db ->query ('SHOW COLUMNS FROM ' .$ table .'; ' );
4647 $ execute = false ;
@@ -54,11 +55,11 @@ function remove_column($table, $name) {
5455 @$ query = $ db ->query ('ALTER TABLE ` ' .$ table .'` DROP COLUMN ` ' .$ name .'`; ' );
5556 }
5657}
57- $ users = array ();
58+ $ _SESSION [ ' users ' ] = array ();
5859function author_to_userid ($ table , $ column = 'author ' ) {
5960
60- global $ db ;
61- global $ users ;
61+ $ db = ConnectionManager:: getDataSource ( ' default ' ) ;
62+
6263 $ verif = $ db ->query ('SHOW COLUMNS FROM ' .$ table .'; ' );
6364 $ execute = false ;
6465 foreach ($ verif as $ k => $ v ) {
@@ -75,15 +76,15 @@ function author_to_userid($table, $column = 'author') {
7576 $ table_author_id = $ value [$ table ]['id ' ];
7677 $ author_name = $ value [$ table ][$ column ];
7778
78- if (isset ($ users [$ author_name ])) {
79- $ author_id = $ users [$ author_name ];
79+ if (isset ($ _SESSION [ ' users ' ] [$ author_name ])) {
80+ $ author_id = $ _SESSION [ ' users ' ] [$ author_name ];
8081 } else {
8182 // on le cherche
8283 $ search_author = $ db ->query ('SELECT id FROM users WHERE pseudo= \'' .$ author_name .'\'' );
8384 if (!empty ($ search_author )) {
84- $ author_id = $ users [$ author_name ] = $ search_author [0 ]['users ' ]['id ' ];
85+ $ author_id = $ _SESSION [ ' users ' ] [$ author_name ] = $ search_author [0 ]['users ' ]['id ' ];
8586 } else {
86- $ author_id = $ users [$ author_name ] = 0 ;
87+ $ author_id = $ _SESSION [ ' users ' ] [$ author_name ] = 0 ;
8788 }
8889 }
8990
0 commit comments