IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

PHP 7.2.1 sous MAMP + update mysql = fail


Sujet :

PHP & Base de données

  1. #1
    Membre confirmé Avatar de 01001111
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2009
    Messages
    319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Loire (Auvergne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2009
    Messages : 319
    Points : 509
    Points
    509
    Par défaut PHP 7.2.1 sous MAMP + update mysql = fail
    Bonjour, j'ai une petite question à propos de php 7.2.1, y a-t-il des changements notables dans la manière de faire une requête par PDO ?
    J'essaie de faire ceci, qui marche parfaitement sous php 7.1.19 sous MAMP OSX mais pas sous php 7.2.1 sous MAMP OSX :
    description du résultat :
    insert ok et update ok php 7.1.19
    insert ok et update ko php 7.2.1 alors que le script renvoie ok pour l'update aussi

    merci d'avance à qui voudra bien se pencher sur le pb (peut-être un bug de la compilation 7.2.1 par appsolute, ou bien erreur de ma part ? )

    fichier index.php
    Code PHP : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    <?php
    include_once('./mysql_utils.php');
    $mysql=new mysqlUtils();
    if ($mysql::$statusReturn[0]) {
    	$r=$mysql::insertAll("test_table", ["value"=>2]);
    	print_r($r);
    	$r=$mysql::updateWhere("test_table", ["value"=>3], [["name"=>"id","operator"=>">","value"=>0,"and|or"=>null]], "limit 1");
    	print_r($r);
    }
    ?>
    fichier mysql_utils.php (c'est un peu long pour un forum désolé) je joins une archive de test ici:https://laplumesurlatoile.com/testPDOphp72.zip
    Code PHP : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    <?php
    class mysqlUtils {
    	public static $statusReturn=array(false, "notInitiated");
    	public static $mysqlLink=false;
    	public static $mysqlBase=false;
    	function __construct($base="") {
    		self::connection($base);
    	}
    	private static function connection($base) {
    		if (file_exists(__DIR__.'/utils.php') && file_exists(__DIR__.'/mysql_credentials.php')) {
    			include_once(__DIR__.'/utils.php');
    			include_once(__DIR__.'/mysql_credentials.php');
    			$mysqlCredentials=new mysqlCredentials();
    			self::$mysqlBase=(!empty($base)?$base:$mysqlCredentials::$base);
    			try {
    				$dsn = 'mysql:dbname='.self::$mysqlBase.';host='.$mysqlCredentials::$host;
    				$dbh = new PDO($dsn, $mysqlCredentials::$user, $mysqlCredentials::$pass);
    				self::$mysqlLink=$dbh;
    				self::$statusReturn=array(true, self::$mysqlLink);
    				self::$mysqlLink->exec('set names utf8');
    			} catch (PDOException $e) {
    				self::$statusReturn=array(false, "failedToConnect", $e->getMessage());
    			}
    		} else {
    			self::$statusReturn=array(false, "includeOfDependenciesImpossible");
    		}
    	}
    	public static function query($query) {
    		if (self::$statusReturn[0]) {
    			$statement=self::$mysqlLink->prepare($query);
    			$res=array();
    			try {
    				$statement->execute();
    				$res=$statement->fetchColumn();
    				return array("result"=>$res);
    			} catch (PDOException $e) {
    				return array("message"=>"ko","error"=>$e->getMessage());
    			}
    			$statement->closeCursor();
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function selectCount($table, $field) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$sql="select count(".$field.") from ".$table;
    				$statement=self::$mysqlLink->prepare($sql);
    				$res=array();
    				try {
    					$statement->execute();
    					$res=$statement->fetchColumn();
    					if (preg_match('/[0-9]+/', $res)) {
    						return array("message"=>"ok","count"=>$res);
    					} else if (empty($res)) {
    						return array("message"=>"ko","error"=>"tableDoesNotExist");
    					} else {
    						return array("message"=>"ko","error"=>"unknownError");
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    				$statement->closeCursor();
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function selectCountWhereString($table, $field, $whereString) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$sql="select count(".$field.") from ".$table." where ".$whereString;
    				$statement=self::$mysqlLink->prepare($sql);
    				$res=array();
    				try {
    					$statement->execute();
    					$res=$statement->fetchColumn();
    					if (preg_match('/[0-9]+/', $res)) {
    						return array("message"=>"ok","count"=>$res);
    					} else if (empty($res)) {
    						return array("message"=>"ko","error"=>"tableDoesNotExist");
    					} else {
    						return array("message"=>"ko","error"=>"unknownError");
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    				$statement->closeCursor();
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function selectAll($table, $treatmentFunction, $sortParameters=array("boolean"=>false, "key"=>null, "sort_flags"=>null, "boolean_remap_numerical"=>false)) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$sql="select * from ".$table;
    				$statement=self::$mysqlLink->prepare($sql);
    				$res=array();
    				try {
    					$statement->execute();
    					while ($r=$statement->fetch(PDO::FETCH_ASSOC)) {
    						if (is_array($r)) {
    							foreach($r as $k => $v) {
    								if (!array_key_exists($k, $res)) {
    									$res[$k]=array();
    								}
    								$res[$k][].=(($treatmentFunction!=null)?$treatmentFunction($v):$v);
    							}
    						}
    					}
    					unset($r);
    					if ($sortParameters["boolean"]==false) {
    						return $res;
    					} else {
    						if (is_array($sortParameters["key"])) {
    							$sortParameters["key"]=array_reverse($sortParameters["key"]);
    							foreach($sortParameters["key"] as $k=>$v) {
    								$res=sortOn($res, $sortParameters["key"][$k], $sortParameters["sort_flags"], $sortParameters["boolean_remap_numerical"]);
    							}
    						}
    						return $res;
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    				$statement->closeCursor();
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function selectOnFields($tableAndFields, $treatmentFunction, $sortParameters=array("boolean"=>false, "key"=>null, "sort_flags"=>null, "boolean_remap_numerical"=>false)) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $tableAndFields[0])) {
    				$sql="select ";
    				for ($i=0; $i<count($tableAndFields[1]); $i++) {
    					$sql.=$tableAndFields[1][$i];
    					if ($i<count($tableAndFields[1])-1) {
    						$sql.=', ';
    					}
    				}
    				$sql.=" from ".$tableAndFields[0];
    				$statement=self::$mysqlLink->prepare($sql);
    				$res=array();
    				try {
    					$statement->execute();
    					while ($r=$statement->fetch(PDO::FETCH_ASSOC)) {
    						if (is_array($r)) {
    							foreach($r as $k => $v) {
    								if (!array_key_exists($k, $res)) {
    									$res[$k]=array();
    								}
    								$res[$k][].=(($treatmentFunction!=null)?$treatmentFunction($v):$v);
    							}
    						}
    					}
    					unset($r);
    					if ($sortParameters["boolean"]==false) {
    						return $res;
    					} else {
    						if (is_array($sortParameters["key"])) {
    							$sortParameters["key"]=array_reverse($sortParameters["key"]);
    							foreach($sortParameters["key"] as $k=>$v) {
    								$res=sortOn($res, $sortParameters["key"][$k], $sortParameters["sort_flags"], $sortParameters["boolean_remap_numerical"]);
    							}
    						}
    						return $res;
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    				$statement->closeCursor();
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function selectAllForId($table, $id, $treatmentFunction, $sortParameters=array("boolean"=>false, "key"=>null, "sort_flags"=>null, "boolean_remap_numerical"=>false)) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$statement=self::$mysqlLink->prepare("select * from ".$table." where id=:id");
    				$statement->bindParam(':id', $id, PDO::PARAM_INT);
    				$statement->execute();
    				try {
    					$r=$statement->fetch(PDO::FETCH_ASSOC);
    					$res=array();
    					foreach($r as $k => $v) {
    						if (!array_key_exists($k, $res)) {
    							$res[$k]=array();
    						}
    						$res[$k][].=(($treatmentFunction!=null)?$treatmentFunction($v):$v);
    					}
    					unset($r);
    					$statement->closeCursor();
    					if ($sortParameters["boolean"]==false) {
    						return $res;
    					} else {
    						if (is_array($sortParameters["key"])) {
    							$sortParameters["key"]=array_reverse($sortParameters["key"]);
    							foreach($sortParameters["key"] as $k=>$v) {
    								$res=sortOn($res, $sortParameters["key"][$k], $sortParameters["sort_flags"], $sortParameters["boolean_remap_numerical"]);
    							}
    						}
    						return $res;
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function selectAllWhere($table, $whereArray, $treatmentFunction, $sortParameters=array("boolean"=>false, "key"=>null, "sort_flags"=>null, "boolean_remap_numerical"=>false)) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$intTypes=array("tinyint","smallint","mediumint","int","bigint");
    				$sql="select * from ".$table." where ";
    				$type=array();
    				foreach ($whereArray as $k => $v) {
    					$statement=self::$mysqlLink->prepare("select data_type from information_schema.columns where table_schema='".self::$mysqlBase."' and table_name=:table and column_name=:column");
    					$statement->bindParam(':table', $table, PDO::PARAM_STR);
    					$statement->bindParam(':column', $whereArray[$k]["name"], PDO::PARAM_STR);
    					try {
    						$statement->execute();
    						$r=$statement->fetch(PDO::FETCH_ASSOC);
    						$type[$k]=$r['data_type'];
    						$statement->closeCursor();
    					} catch (PDOException $e) {
    						return array("message"=>"ko","error"=>$e->getMessage());
    					}
    					if (strlen($type[$k])>0 && in_array(strtolower($type[$k]),$intTypes)) {
    						$type[$k]=PDO::PARAM_INT;
    					} else {
    						$type[$k]=PDO::PARAM_STR;
    					}
    					$sql.=$whereArray[$k]["name"]." ".$whereArray[$k]["operator"]." :".$whereArray[$k]["name"].$k;
    					if ($k<count($whereArray)-1) {
    						$sql.=" ".$whereArray[$k]["and|or"]." ";
    					}
    				}
    				$statement=self::$mysqlLink->prepare($sql);
    				foreach ($whereArray as $k => $v) {
    					$statement->bindParam(':'.$whereArray[$k]["name"].$k, $whereArray[$k]["value"], $type[$k]);
    				}
    				try {
    					$statement->execute();
    					$res=array();
    					while ($r=$statement->fetch(PDO::FETCH_ASSOC)) {
    						if (is_array($r)) {
    							foreach($r as $k => $v) {
    								if (!array_key_exists($k, $res)) {
    									$res[$k]=array();
    								}
    								$res[$k][].=(($treatmentFunction!=null)?$treatmentFunction($v):$v);
    							}
    						}
    						unset($r);
    					}
    					$statement->closeCursor();
    					if ($sortParameters["boolean"]==false) {
    						return $res;
    					} else {
    						if (is_array($sortParameters["key"])) {
    							$sortParameters["key"]=array_reverse($sortParameters["key"]);
    							foreach($sortParameters["key"] as $k=>$v) {
    								$res=sortOn($res, $sortParameters["key"][$k], $sortParameters["sort_flags"], $sortParameters["boolean_remap_numerical"]);
    							}
    						}
    						return $res;
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function selectOnFieldsWhere($tableAndFields, $whereArray, $treatmentFunction, $sortParameters=array("boolean"=>false, "key"=>null, "sort_flags"=>null, "boolean_remap_numerical"=>false)) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $tableAndFields[0])) {
    				$intTypes=array("tinyint","smallint","mediumint","int","bigint");
    				$sql="select ";
    				for ($i=0; $i<count($tableAndFields[1]); $i++) {
    					$sql.=$tableAndFields[1][$i];
    					if ($i<count($tableAndFields[1])-1) {
    						$sql.=', ';
    					}
    				}
    				$sql.=" from ".$tableAndFields[0]." where ";
    				$type=array();
    				foreach ($whereArray as $k => $v) {
    					$statement=self::$mysqlLink->prepare("select data_type from information_schema.columns where table_schema='".self::$mysqlBase."' and table_name=:table and column_name=:column");
    					$statement->bindParam(':table', $tableAndFields[0], PDO::PARAM_STR);
    					$statement->bindParam(':column', $whereArray[$k]["name"], PDO::PARAM_STR);
    					try {
    						$statement->execute();
    						$r=$statement->fetch(PDO::FETCH_ASSOC);
    						$type[$k]=$r['data_type'];
    						$statement->closeCursor();
    					} catch (PDOException $e) {
    						return array("message"=>"ko","error"=>$e->getMessage());
    					}
    					if (strlen($type[$k])>0 && in_array(strtolower($type[$k]),$intTypes)) {
    						$type[$k]=PDO::PARAM_INT;
    					} else {
    						$type[$k]=PDO::PARAM_STR;
    					}
    					$sql.=$whereArray[$k]["name"]." ".$whereArray[$k]["operator"]." :".$whereArray[$k]["name"].$k;
    					if ($k<count($whereArray)-1) {
    						$sql.=" ".$whereArray[$k]["and|or"]." ";
    					}
    				}
    				$statement=self::$mysqlLink->prepare($sql);
    				foreach ($whereArray as $k => $v) {
    					$statement->bindParam(':'.$whereArray[$k]["name"].$k, $whereArray[$k]["value"], $type[$k]);
    				}
    				try {
    					$statement->execute();
    					$res=array();
    					while ($r=$statement->fetch(PDO::FETCH_ASSOC)) {
    						if (is_array($r)) {
    							foreach($r as $k => $v) {
    								if (!array_key_exists($k, $res)) {
    									$res[$k]=array();
    								}
    								$res[$k][].=(($treatmentFunction!=null)?$treatmentFunction($v):$v);
    							}
    						}
    						unset($r);
    					}
    					$statement->closeCursor();
    					if ($sortParameters["boolean"]==false) {
    						return $res;
    					} else {
    						if (is_array($sortParameters["key"])) {
    							$sortParameters["key"]=array_reverse($sortParameters["key"]);
    							foreach($sortParameters["key"] as $k=>$v) {
    								$res=sortOn($res, $sortParameters["key"][$k], $sortParameters["sort_flags"], $sortParameters["boolean_remap_numerical"]);
    							}
    						}
    						return $res;
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function selectAllPlusString($table, $string, $treatmentFunction, $sortParameters=array("boolean"=>false, "key"=>null, "sort_flags"=>null, "boolean_remap_numerical"=>false)) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$sql="select * from ".$table." ";
    				$sql.=$string;
    				$statement=self::$mysqlLink->prepare($sql);
    				try {
    					$statement->execute();
    					$res=array();
    					while ($r=$statement->fetch(PDO::FETCH_ASSOC)) {
    						foreach($r as $k => $v) {
    							if (!array_key_exists($k, $res)) {
    								$res[$k]=array();
    							}
    							$res[$k][].=(($treatmentFunction!=null)?$treatmentFunction($v):$v);
    						}
    						unset($r);
    					}
    					$statement->closeCursor();
    					if ($sortParameters["boolean"]==false) {
    						return $res;
    					} else {
    						if (is_array($sortParameters["key"])) {
    							$sortParameters["key"]=array_reverse($sortParameters["key"]);
    							foreach($sortParameters["key"] as $k=>$v) {
    								$res=sortOn($res, $sortParameters["key"][$k], $sortParameters["sort_flags"], $sortParameters["boolean_remap_numerical"]);
    							}
    						}
    						return $res;
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function selectOnFieldsPlusString($tableAndFields, $string, $treatmentFunction, $sortParameters=array("boolean"=>false, "key"=>null, "sort_flags"=>null, "boolean_remap_numerical"=>false)) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $tableAndFields[0])) {
    				$sql="select ";
    				for ($i=0; $i<count($tableAndFields[1]); $i++) {
    					$sql.=$tableAndFields[1][$i];
    					if ($i<count($tableAndFields[1])-1) {
    						$sql.=', ';
    					}
    				}
    				$sql.=" from ".$tableAndFields[0]." ";
    				$sql.=$string;
    				$statement=self::$mysqlLink->prepare($sql);
    				try {
    					$statement->execute();
    					$res=array();
    					while ($r=$statement->fetch(PDO::FETCH_ASSOC)) {
    						if (is_array($r)) {
    							foreach($r as $k => $v) {
    								if (!array_key_exists($k, $res)) {
    									$res[$k]=array();
    								}
    								$res[$k][].=(($treatmentFunction!=null)?$treatmentFunction($v):$v);
    							}
    						}
    						unset($r);
    					}
    					$statement->closeCursor();
    					if ($sortParameters["boolean"]==false) {
    						return $res;
    					} else {
    						if (is_array($sortParameters["key"])) {
    							$sortParameters["key"]=array_reverse($sortParameters["key"]);
    							foreach($sortParameters["key"] as $k=>$v) {
    								$res=sortOn($res, $sortParameters["key"][$k], $sortParameters["sort_flags"], $sortParameters["boolean_remap_numerical"]);
    							}
    						}
    						return $res;
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function insertAll($table, $keyValueArray) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$intTypes=array("tinyint","smallint","mediumint","int","bigint");
    				$ins="insert into ".$table." (";
    				$select="select id from ".$table." where ";
    				$i=0;
    				foreach ($keyValueArray as $k => $v) {
    					$ins.=$k;
    					if ($i<count($keyValueArray)-1) {
    						$ins.=", ";
    					}
    					$i++;
    				}
    				$ins.=") values (";
    				$i=0;
    				$type=array();
    				foreach ($keyValueArray as $k => $v) {
    					$statement=self::$mysqlLink->prepare("select data_type from information_schema.columns where table_schema='".self::$mysqlBase."' and table_name=:table and column_name=:column");
    					$statement->bindParam(':table', $table, PDO::PARAM_STR);
    					$statement->bindParam(':column', $k, PDO::PARAM_STR);
    					try {
    						$statement->execute();
    						$r=$statement->fetch(PDO::FETCH_ASSOC);
    						$type[$k]=$r['data_type'];
    						$statement->closeCursor();
    					} catch (PDOException $e) {
    						return array("message"=>"ko","error"=>$e->getMessage());
    					}
    					$quotes=false;
    					if (strlen($type[$k])>0 && in_array(strtolower($type[$k]),$intTypes)) {
    						$type[$k]=PDO::PARAM_INT;
    					} else {
    						$type[$k]=PDO::PARAM_STR;
    					}
    					$ins.=':'.$k;
    					$select.=$k."=:".$k;
    					if ($i<count($keyValueArray)-1) {
    						$ins.=", ";
    						$select.=" and ";
    					}
    					$i++;
    				}
    				$ins.=")";
    				$statement=self::$mysqlLink->prepare($ins);
    				$statementId=self::$mysqlLink->prepare($select);
    				foreach ($keyValueArray as $k => $v) {
    					$statement->bindParam(':'.$k, $keyValueArray[$k], $type[$k]);
    					$statementId->bindParam(':'.$k, $keyValueArray[$k], $type[$k]);
    				}
    				try {
    					$req=$statement->execute();
    					if (!$req) {
    						return array("message"=>"ko","error"=>implode(", ", $statement->errorInfo()));
    					} else {
    						try {
    							$req=$statementId->execute();
    							if (!$req) {
    								return array("message"=>"ko","error"=>implode(", ", $statementId->errorInfo()));
    							} else {
    								$id="";
    								while ($rId=$statementId->fetch(PDO::FETCH_ASSOC)) {
    									$id=$rId['id'];
    								}
    								$statementId->closeCursor();
    								if ((int)$id>0) {
    									return array("message"=>"ok","id"=>$id);
    								} else {
    									return array("message"=>"ok","id"=>null,"error"=>"erreur inconnue");
    								}
    							}
    						} catch (PDOException $e) {
    							return array("message"=>"ko","id"=>null,"error"=>$e->getMessage());
    						}
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","id"=>null,"error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","id"=>null,"error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function updateWhere($table, $keyValueArray, $whereArray, $additionnalString="") {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$intTypes=array("tinyint","smallint","mediumint","int","bigint");
    				$upd="update ".$table." set ";
    				$type=array();
    				$uniqid=array();
    				foreach ($keyValueArray as $k => $v) {
    					if (substr($k, 0, 5)!="where") {
    						$statement=self::$mysqlLink->prepare("select data_type from information_schema.columns where table_schema='".self::$mysqlBase."' and table_name=:table and column_name=:column");
    						$statement->bindParam(':table', $table, PDO::PARAM_STR);
    						$statement->bindParam(':column', $k, PDO::PARAM_STR);
    						try {
    							$statement->execute();
    							$r=$statement->fetch(PDO::FETCH_ASSOC);
    							$type[$k]=$r['data_type'];
    							$statement->closeCursor();
    						} catch (PDOException $e) {
    							return array("message"=>"ko","error"=>$e->getMessage());
    						}
    						$quotes=false;
    						if (strlen($type[$k])>0 && in_array(strtolower($type[$k]),$intTypes)) {
    							$type[$k]=PDO::PARAM_INT;
    						} else {
    							$type[$k]=PDO::PARAM_STR;
    						}
    						$uniqid[$k]=uniqid();
    						$upd.=$k."=:".$k.$uniqid[$k];
    						$upd.=", ";
    					}
    				}
    				$upd=substr($upd, 0, strlen($upd)-2)." where ";
    				for ($i=0; $i<count($whereArray); $i++) {
    					if (array_key_exists($i, $whereArray) && is_array($whereArray[$i])) {
    						$statement=self::$mysqlLink->prepare("select data_type from information_schema.columns where table_schema='".self::$mysqlBase."' and table_name=:table and column_name=:column");
    						$statement->bindParam(':table', $table, PDO::PARAM_STR);
    						$statement->bindParam(':column', $whereArray[$i]["name"], PDO::PARAM_STR);
    						$typeWhere=array();
    						try {
    							$r=$statement->execute();
    							$typeWhere[$i]=$r[0];
    							$statement->closeCursor();
    						} catch (PDOException $e) {
    							error_log(1,0);
    							return array("message"=>"ko","error"=>$e->getMessage());
    						}
    						$upd.=$whereArray[$i]["name"]." ".$whereArray[$i]["operator"]." :".$whereArray[$i]["name"];
    						if ($whereArray[$i]["and|or"]!==null) {
    							$upd.=" ".$whereArray[$i]["and|or"]." ";
    						}
    					} else {
    						return array("message"=>"ko","error"=>"whereClauseBadlyWritten");
    					}
    				}
    				$upd.=" ".$additionnalString;
    				$statement=self::$mysqlLink->prepare($upd);
    				foreach ($keyValueArray as  $k => $v) {
    					$statement->bindParam(':'.$k.$uniqid[$k], $keyValueArray[$k], $type[$k]);
    				}
    				for ($i=0; $i<count($whereArray); $i++) {
    					if (array_key_exists($i, $whereArray) && is_array($whereArray[$i])) {
    						$statement->bindParam(":".$whereArray[$i]["name"], $whereArray[$i]["value"], $typeWhere[$i]);
    					} else {
    						return array("message"=>"ko","error"=>"whereClauseBadlyWritten");
    					}
    				}
    				try {
    					$req=$statement->execute();
    					if (!$req) {
    						return array("message"=>"ko","error"=>implode(", ", $statement->errorInfo()));
    					} else {
    						$statement->closeCursor();
    						return array("message"=>"ok");
    					}
    				} catch (PDOException $e) {
    					error_log(2,0);
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function updatePlusString($table, $keyValueArray, $plus) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$intTypes=array("tinyint","smallint","mediumint","int","bigint");
    				$upd="update ".$table." set ";
    				$type=array();
    				$uniqid=array();
    				foreach ($keyValueArray as $k => $v) {
    					if (substr($k, 0, 5)!="where") {
    						$statement=self::$mysqlLink->prepare("select data_type from information_schema.columns where table_schema='".self::$mysqlBase."' and table_name=:table and column_name=:column");
    						$statement->bindParam(':table', $table, PDO::PARAM_STR);
    						$statement->bindParam(':column', $k, PDO::PARAM_STR);
    						try {
    							$statement->execute();
    							$r=$statement->fetch(PDO::FETCH_ASSOC);
    							$type[$k]=$r['data_type'];
    							$statement->closeCursor();
    						} catch (PDOException $e) {
    							return array("message"=>"ko","error"=>$e->getMessage());
    						}
    						$quotes=false;
    						if (strlen($type[$k])>0 && in_array(strtolower($type[$k]),$intTypes)) {
    							$type[$k]=PDO::PARAM_INT;
    						} else {
    							$type[$k]=PDO::PARAM_STR;
    						}
    						$uniqid[$k]=uniqid();
    						$upd.=$k."=:".$k.$uniqid[$k];
    						$upd.=", ";
    					}
    				}
    				$upd=substr($upd, 0, strlen($upd)-2)." where ".$plus;
    				$statement=self::$mysqlLink->prepare($upd);
    				foreach ($keyValueArray as  $k => $v) {
    					$statement->bindParam(':'.$k.$uniqid[$k], $keyValueArray[$k], $type[$k]);
    				}
    				try {
    					$req=$statement->execute();
    					if (!$req) {
    						return array("message"=>"ko","error"=>implode(", ", $statement->errorInfo()));
    					} else {
    						$statement->closeCursor();
    						return array("message"=>"ok");
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function deleteWhereId($table, $id) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$statement=self::$mysqlLink->prepare("delete from ".$table." where id=:id");
    				$statement->bindParam(':id', $id, PDO::PARAM_INT);
    				try {
    					$req=$statement->execute();
    					if (!$req) {
    						return array("message"=>"ko","error"=>implode(", ", $statement->errorInfo()));
    					} else {
    						$statement->closeCursor();
    						return array("message"=>"ok");
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function deleteWhere($table, $whereArray) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$intTypes=array("tinyint","smallint","mediumint","int","bigint");
    				$sql="delete from ".$table." where ";
    				$type=array();
    				foreach ($whereArray as $k => $v) {
    					$statement=self::$mysqlLink->prepare("select data_type from information_schema.columns where table_schema='".self::$mysqlBase."' and table_name=:table and column_name=:column");
    					$statement->bindParam(':table', $table, PDO::PARAM_STR);
    					$statement->bindParam(':column', $whereArray[$k]["name"], PDO::PARAM_STR);
    					try {
    						$statement->execute();
    						$r=$statement->fetch(PDO::FETCH_ASSOC);
    						$type[$k]=$r['data_type'];
    						$statement->closeCursor();
    					} catch (PDOException $e) {
    						return array("message"=>"ko","error"=>$e->getMessage());
    					}
    					if (strlen($type[$k])>0 && in_array(strtolower($type[$k]),$intTypes)) {
    						$type[$k]=PDO::PARAM_INT;
    					} else {
    						$type[$k]=PDO::PARAM_STR;
    					}
    					$sql.=$whereArray[$k]["name"]." ".$whereArray[$k]["operator"]." :".$whereArray[$k]["name"].$k;
    					if ($k<count($whereArray)-1) {
    						$sql.=" ".$whereArray[$k]["and|or"]." ";
    					}
    				}
    				$statement=self::$mysqlLink->prepare($sql);
    				foreach ($whereArray as $k => $v) {
    					$statement->bindParam(':'.$whereArray[$k]["name"].$k, $whereArray[$k]["value"], $type[$k]);
    				}
    				try {
    					$req=$statement->execute();
    					if (!$req) {
    						return array("message"=>"ko","error"=>implode(", ", $statement->errorInfo()));
    					} else {
    						$statement->closeCursor();
    						return array("message"=>"ok");
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function deleteWhereString($table, $whereString) {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$sql="delete from ".$table." where ".$whereString;
    				$statement=self::$mysqlLink->prepare($sql);
    				try {
    					$req=$statement->execute();
    					if (!$req) {
    						return array("message"=>"ko","error"=>implode(", ", $statement->errorInfo()));
    					} else {
    						$statement->closeCursor();
    						return array("message"=>"ok");
    					}
    				} catch (PDOException $e) {
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}
    	public static function closeMysql() {
    		self::$mysqlLink=null;
    	}
    }
    ?>
    0x4F

  2. #2
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Bonjour,

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $dbh = new PDO($dsn, $mysqlCredentials::$user, $mysqlCredentials::$pass);
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $dbh = new PDO($dsn, $mysqlCredentials::$user, $mysqlCredentials::$pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
    Ensuite,
    Code sql : Sélectionner tout - Visualiser dans une fenêtre à part
    select data_type from information_schema.columns
    Tu peux ne pas avoir accès à cette base quand tu hébergeras ton appli.

    A+.

  3. #3
    Membre confirmé Avatar de 01001111
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2009
    Messages
    319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Loire (Auvergne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2009
    Messages : 319
    Points : 509
    Points
    509
    Par défaut
    merci pour l'info à propos des droits, je teste le reste de la réponse

    Citation Envoyé par andry.aime Voir le message
    Bonjour,


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $dbh = new PDO($dsn, $mysqlCredentials::$user, $mysqlCredentials::$pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
    Ensuite,
    Tu peux ne pas avoir accès à cette base quand tu hébergeras ton appli.

    A+.
    0x4F

  4. #4
    Membre confirmé Avatar de 01001111
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2009
    Messages
    319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Loire (Auvergne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2009
    Messages : 319
    Points : 509
    Points
    509
    Par défaut
    suite : j'ai appliqué les consignes et vais me renseigner sur l'accessibilité en lecture seule de la table information_schema chez différents hébergeurs... Pour l'instant le travail que je fais est destiné à être hébergé sur un serveur dédié que j'administre donc pas de souci.
    donc en faisant ce que tu m'as conseillé, ça n'est pas plus verbeux, malheureusement.
    Mysql sous MAMP refuse l'update.
    Quelqu'un a-t-il les moyens de tester mon archive sous un php 7.2 sous une quelconque plateforme ?

    Sinon je vais installer un serveur LAMP sous Debian 9 et tester de mon côté, pour voir si le problème se reproduit
    merci
    0x4F

  5. #5
    Rédacteur/Modérateur
    Avatar de andry.aime
    Homme Profil pro
    Inscrit en
    Septembre 2007
    Messages
    8 391
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Ile Maurice

    Informations forums :
    Inscription : Septembre 2007
    Messages : 8 391
    Points : 15 059
    Points
    15 059
    Par défaut
    Bonjour,

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    self::$mysqlLink->exec('set names utf8');
    Passe le directement dans le dns pendant l'instanciation de ton PDO
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $dbh = new PDO($dsn.';charset=UTF8', $mysqlCredentials::$user, $mysqlCredentials::$pass, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]);
    Tu dois mettre cette ligne avant la boucle for
    sinon ça réinitialise à chaque itération et tu pourras avoir un erreur Undefined offset

    A+.

  6. #6
    Membre confirmé Avatar de 01001111
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2009
    Messages
    319
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Haute Loire (Auvergne)

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2009
    Messages : 319
    Points : 509
    Points
    509
    Par défaut
    Oups, sorry j'avais dit que ça réglait le problème, mais comme un idiot je n'avais pas redémarré en php 7.2
    merci en effet pour le conseil n°1 comme pour le n°2 mais cela ne règle pas ce problème précis,
    en revanche le numéro 2 reglerait des offsets indéfinis sur un where à plusieurs conditions.

    Edit: J'ai trouvé, il fallait enlever l'index [0] sur $r dans la partie qui va chercher le typeWhere[$i]... bizarrement pdo semble renvoyer non pas un tableau mais un nombre seul
    merci de m'avoir mis sur la piste !
    ou plus proprement avec pdo fetch assoc :
    Code php : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
     
          public static function updateWhere($table, $keyValueArray, $whereArray, $additionnalString="") {
    		if (self::$statusReturn[0]) {
    			if (!preg_match('/[^\\\] /', $table)) {
    				$intTypes=array("tinyint","smallint","mediumint","int","bigint");
    				$upd="update ".$table." set ";
    				$type=array();
    				$uniqid=array();
    				foreach ($keyValueArray as $k => $v) {
    					if (substr($k, 0, 5)!="where") {
    						$statement=self::$mysqlLink->prepare("select data_type from information_schema.columns where table_schema='".self::$mysqlBase."' and table_name=:table and column_name=:column");
    						$statement->bindParam(':table', $table, PDO::PARAM_STR);
    						$statement->bindParam(':column', $k, PDO::PARAM_STR);
    						try {
    							$statement->execute();
    							$r=$statement->fetch(PDO::FETCH_ASSOC);
    							$type[$k]=$r['data_type'];
    							$statement->closeCursor();
    						} catch (PDOException $e) {
    							return array("message"=>"ko","error"=>$e->getMessage());
    						}
    						$quotes=false;
    						if (strlen($type[$k])>0 && in_array(strtolower($type[$k]),$intTypes)) {
    							$type[$k]=PDO::PARAM_INT;
    						} else {
    							$type[$k]=PDO::PARAM_STR;
    						}
    						$uniqid[$k]=uniqid();
    						$upd.=$k."=:".$k.$uniqid[$k];
    						$upd.=", ";
    					}
    				}
    				$upd=substr($upd, 0, strlen($upd)-2)." where ";
    				$typeWhere=[];
    				for ($i=0; $i<count($whereArray); $i++) {
    					if (array_key_exists($i, $whereArray) && is_array($whereArray[$i])) {
    						$statement=self::$mysqlLink->prepare("select data_type from information_schema.columns where table_schema='".self::$mysqlBase."' and table_name=:table and column_name=:column");
    						$statement->bindParam(':table', $table, PDO::PARAM_STR);
    						$statement->bindParam(':column', $whereArray[$i]["name"], PDO::PARAM_STR);
    						try {
    							$statement->execute();
    							$r=$statement->fetch(PDO::FETCH_ASSOC);
    							$typeWhere[$i]=$r['data_type'];
    							$statement->closeCursor();
    						} catch (PDOException $e) {
    							echo 'ko';
    							return array("message"=>"ko","error"=>$e->getMessage());
    						}
    						if (strlen($typeWhere[$i])>0 && in_array(strtolower($typeWhere[$i]),$intTypes)) {
    							$typeWhere[$i]=PDO::PARAM_INT;
    						} else {
    							$typeWhere[$i]=PDO::PARAM_STR;
    						}
    						$upd.=$whereArray[$i]["name"]." ".$whereArray[$i]["operator"]." :".$whereArray[$i]["name"];
    						if ($whereArray[$i]["and|or"]!==null) {
    							$upd.=" ".$whereArray[$i]["and|or"]." ";
    						}
    					} else {
    						return array("message"=>"ko","error"=>"whereClauseBadlyWritten");
    					}
    				}
    				$upd.=" ".$additionnalString;
    				$statement=self::$mysqlLink->prepare($upd);
    				foreach ($keyValueArray as  $k => $v) {
    					$statement->bindParam(':'.$k.$uniqid[$k], $keyValueArray[$k], $type[$k]);
    				}
    				for ($i=0; $i<count($whereArray); $i++) {
    					echo array_key_exists($i, $whereArray) && is_array($whereArray[$i])."<br />";
    					if (array_key_exists($i, $whereArray) && is_array($whereArray[$i])) {
    						echo $typeWhere[$i]."<br />";
    						$statement->bindParam(":".$whereArray[$i]["name"], $whereArray[$i]["value"], $typeWhere[$i]);
    					} else {
    						return array("message"=>"ko","error"=>"whereClauseBadlyWritten");
    					}
    				}
    				try {
    					$req=$statement->execute();
    					if (!$req) {
    						return array("message"=>"ko","error"=>implode(", ", $statement->errorInfo()));
    					} else {
    						$statement->closeCursor();
    						return array("message"=>"ok");
    					}
    				} catch (PDOException $e) {
    					error_log(2,0);
    					return array("message"=>"ko","error"=>$e->getMessage());
    				}
    			} else {
    				return array("message"=>"ko","error"=>"tableStringContainingUnescapedSpaces");
    			}
    		} else {
    			return self::$statusReturn;
    		}
    	}

    puis en fait, je compte utiliser la fonction getColumnMeta pour passer outre les limitations d'accès à information_schema plus tard, ainsi que référencer tous les types mysql
    0x4F

Discussions similaires

  1. Mysql sous MAMP + iphone
    Par hersno dans le forum Développement iOS
    Réponses: 3
    Dernier message: 15/11/2013, 17h35
  2. [MySQL] MYSQL/PHP menu categorie et sous categorie
    Par t0rensen dans le forum PHP & Base de données
    Réponses: 1
    Dernier message: 02/05/2011, 00h27
  3. [MySQL] Update Mysql PHP
    Par serair dans le forum PHP & Base de données
    Réponses: 7
    Dernier message: 15/04/2011, 17h57
  4. [MySQL] Update en PHP foireux mais pas sous MySQL
    Par Gouzoul dans le forum PHP & Base de données
    Réponses: 7
    Dernier message: 08/04/2009, 17h58
  5. [MySQL] requete update mysql php
    Par fasyr dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 24/10/2008, 13h49

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo