From e0abba27c001a630a26aba7d027444824c3be75f Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sun, 6 Oct 2024 23:08:40 +0200 Subject: [PATCH] code for PHP 8.2.20 --- etc/dbq/sqlite-dir.php | 2 +- lib/php/db.php | 16 +++++++++++----- lib/php/db/field.php | 1 + lib/php/db/table.php | 16 +++++++++++++--- lib/php/nb.php | 2 +- lib/php/out.php | 2 +- www/dbq/dbq.php | 1 + 7 files changed, 29 insertions(+), 11 deletions(-) diff --git a/etc/dbq/sqlite-dir.php b/etc/dbq/sqlite-dir.php index a9447fe6..38d7f7f2 100644 --- a/etc/dbq/sqlite-dir.php +++ b/etc/dbq/sqlite-dir.php @@ -29,7 +29,7 @@ foreach ((array)$_SERVER['DBQ_DIRS_SQLITE'] as $DIR_SQLITE) { } $name = basename($file,'.db'); - $id = "${name}-sqlite"; + $id = $name."-sqlite"; if (empty($DBQ[$name])) $id = $name; if (!isset($DBQ[$id])) $DBQ[$id] = [ diff --git a/lib/php/db.php b/lib/php/db.php index bbac9c9f..12d668a6 100644 --- a/lib/php/db.php +++ b/lib/php/db.php @@ -35,13 +35,14 @@ class Db extends nb { # NB 10.09.18 ]; public $conn; - public $pdo; + public $pdo = ''; public $options = [ # See: http://php.net/manual/en/pdo.error-handling.php PDO::ATTR_ERRMODE => DB_DEFAUL_ERRMODE, PDO::ATTR_TIMEOUT => 0, ]; - public $host = null; + public $host = ''; public $port = null; + public $dbname = null; public $user = null; public $password = null; public $charset = 'utf8'; @@ -132,6 +133,11 @@ class Db extends nb { # Classes public $out; + # Others + public $is_html; + private $_tables; + private $databases; + function __construct($opt = []) { # Args defaults @@ -202,7 +208,7 @@ class Db extends nb { $this->$k = $v; } - if (empty($this->type)) $this->type = strtolower(preg_replace('/^([^:]+):.*$/','\1',$this->pdo)); + if (empty($this->type)) $this->type = strtolower(preg_replace('/^([^:]+):.*$/','\1',''.$this->pdo)); if (!$this->type) return false; if ($v = $this->p('db_host')) $this->host = $v; @@ -996,13 +1002,13 @@ class Db extends nb { public static function pdo2h($pdo) { $hash = []; - if (preg_match('/^(\w+):(.*)/',$pdo,$m)) { + if (preg_match('/^(\w+):(.*)/',''.$pdo,$m)) { $hash['type'] = $m[1]; $pdo = $m[2]; } # YES - 'use_path' - while (preg_match('/^(\w+)=([^;]*)(?:;?)(.*?)$/',$pdo,$m)) { + while (preg_match('/^(\w+)=([^;]*)(?:;?)(.*?)$/',''.$pdo,$m)) { if ($m[1] == 'dbname') $m[1] = 'name'; $hash[$m[1]] = $m[2]; $pdo = $m[3]; diff --git a/lib/php/db/field.php b/lib/php/db/field.php index ea28b199..91155c4d 100644 --- a/lib/php/db/field.php +++ b/lib/php/db/field.php @@ -9,6 +9,7 @@ class field extends nb { public $key = 0; public $uniq = 0; public $index = 0; + public $size; public $default; public $autoincrement; public $extra; diff --git a/lib/php/db/table.php b/lib/php/db/table.php index a6432b90..ded5214a 100644 --- a/lib/php/db/table.php +++ b/lib/php/db/table.php @@ -32,6 +32,9 @@ Class Table extends nb { public $count; public $engine; public $created; + public $base; + private $_create_temporary; + private $_fields; public static $is_admin = true; # NB 28.07.18 public $key_preff = '_key_'; public $key_preff = ''; @@ -53,6 +56,11 @@ Class Table extends nb { public $show_url_sort = true; public $show_header = true; + # Others + private $tot; + private $limit; + private $status; + function __construct($name,$opt=[]) { if (!is_scalar($name)) { @@ -100,7 +108,9 @@ Class Table extends nb { } // Add others - foreach ($opt as $k => $v) { $this->$k = $v; } + foreach ($opt as $k => $v) { + if (property_exists($this,$k)) $this->$k = $v; + } if (empty($this->db()->limit)) { if ($this->p('paged')) { @@ -421,7 +431,7 @@ Class Table extends nb { 'table' => $this, 'name' => $row['name'], 'type' => strtolower($row['type']), - 'key' => (preg_match('/^(f.*|no|0)?\s*$/i',$row['key']) ? 0 : 1), + 'key' => (preg_match('/^(f.*|no|0)?\s*$/i',''.$row['key']) ? 0 : 1), 'index' => (empty($indexes[$row['name']]) ? 0 : $indexes[$row['name']]), 'null' => (preg_match('/^(f.*|no|0)?\s*$/i',$row['null']) ? 0 : 1), 'extra' => (isset($row['extra']) ? $row['extra'] : null), # !!! nothing todo with array $extra, this info from the sql server @@ -815,7 +825,7 @@ Class Table extends nb { // No empty values $v = isset($values[$k]) ? $values[$k] : null; - if (strcmp($v,'')==0 or $v=='!' or $v=='~') continue; + if (strcmp(''.$v,'')==0 or $v=='!' or $v=='~') continue; // Equal / Not Equal $equal = '='; diff --git a/lib/php/nb.php b/lib/php/nb.php index 853f796d..175c97cd 100644 --- a/lib/php/nb.php +++ b/lib/php/nb.php @@ -868,7 +868,7 @@ class Nb { * Return the head Accept from the client */ public static function client_content_type($default='') { - $v = explode(',', self::client_header('Accept')); + $v = explode(',', ''.self::client_header('Accept')); return ( ($v and $v[0] != '*/*') ? $v[0] : $default ); } diff --git a/lib/php/out.php b/lib/php/out.php index d03e47ba..0c015225 100644 --- a/lib/php/out.php +++ b/lib/php/out.php @@ -311,7 +311,7 @@ Class Out extends Nb { $type = ''; foreach (array_keys(self::$types) as $t) { - if (preg_match("@^\w+/$t@",self::client_header('Accept'))) return $t; + if (preg_match("@^\w+/$t@",''.self::client_header('Accept'))) return $t; } return $type; diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index 074b9c4c..a62c30aa 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -88,6 +88,7 @@ class DbQ extends nb { # Others public $explode_args = '&'; + private $http; # Object public $page; -- 2.47.3