From a470048b4fb69bb1cbdf002db0ac01d687040d25 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Mon, 2 Jan 2023 21:32:29 +0100 Subject: [PATCH] PHP8.2 Support with MySQL returning the int val as int instead of string previously --- Tests/DblayerComplet.php | 2 +- src/Dblayer.php | 4 ++-- src/Dblayeroo.php | 14 ++++++++------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Tests/DblayerComplet.php b/Tests/DblayerComplet.php index 947128c..9a3719b 100644 --- a/Tests/DblayerComplet.php +++ b/Tests/DblayerComplet.php @@ -320,7 +320,7 @@ class DblayerTest{ENGINE} extends \PHPUnit_Framework_TestCase "with space" => "with space")); $db->disconnect(); // SQLite start at 1, MySQL start at 0... - $this->assertLessThanOrEqual($res, 2); + $this->assertSame($res <= 2 || $res === "Us ou\"r", true); } // Test the unique feature diff --git a/src/Dblayer.php b/src/Dblayer.php index 443db7a..837a05e 100644 --- a/src/Dblayer.php +++ b/src/Dblayer.php @@ -623,7 +623,7 @@ class Dblayer )); return $errors; } - if (! isset($data[$foreign][0])) { +/* if (! isset($data[$foreign][0])) { $errors[] = array("error", sprintf( dgettext( "domframework", @@ -633,7 +633,7 @@ class Dblayer )); return $errors; continue; - } + }*/ } else { if (! array_key_exists($foreign, $d)) { continue; diff --git a/src/Dblayeroo.php b/src/Dblayeroo.php index a1f968d..6b813c4 100644 --- a/src/Dblayeroo.php +++ b/src/Dblayeroo.php @@ -929,7 +929,7 @@ class Dblayeroo if ($col["Key_name"] === "PRIMARY") { $primary = $col["Column_name"]; } else { - if ($col["Non_unique"] === "1") { + if ($col["Non_unique"] === 1 || $col["Non_unique"] === "1") { continue; } if (array_key_exists($col["Key_name"], $unique)) { @@ -984,11 +984,13 @@ class Dblayeroo } $st = self::$instance[$this->dsn]->prepare(" - SELECT TABLE_NAME,COLUMN_NAME, - REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME - FROM information_schema.KEY_COLUMN_USAGE - WHERE REFERENCED_TABLE_NAME=:table AND - TABLE_SCHEMA=:dbname"); + SELECT TABLE_NAME,COLUMN_NAME, + REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME + FROM information_schema.KEY_COLUMN_USAGE + WHERE REFERENCED_TABLE_NAME=:table AND + TABLE_SCHEMA=:dbname + ORDER BY TABLE_NAME ASC + "); $st->execute(array(':dbname' => $this->databasename(), ':table' => $tableName)); $foreignUsedTmp = $st->fetchAll(\PDO::FETCH_ASSOC);