From 63da641a544acf821fa5fa87c2017387f5bbe601 Mon Sep 17 00:00:00 2001 From: Pavel Belyaev Date: Sun, 6 Jun 2021 01:31:36 +0500 Subject: [PATCH] mysql bunfix --- CLASSES/core/LE_MYSQL.php | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/CLASSES/core/LE_MYSQL.php b/CLASSES/core/LE_MYSQL.php index f665874..b806b8a 100644 --- a/CLASSES/core/LE_MYSQL.php +++ b/CLASSES/core/LE_MYSQL.php @@ -71,7 +71,9 @@ class LE_MYSQL $res = $this->l->query($s, $buf); $e = ($this->l->error); - if (!empty($e)) $this->err(($this->c['debug'] ? $e . '
(' . $s . ')' : 'ERR QUERY!!!')); + if (!empty($e)) $this->err(($this->debug ? $e . '
(' . $s . ')' : 'ERR QUERY!!!')); + + unset($e, $buf); return $this->answer($res, $type, $o); @@ -241,6 +243,22 @@ class LE_MYSQL return $id; } + /* + public function SELECT($tbl,$fields,$where,$order) + { + $fields = $this->gen_f($fields); + $tbl = $this->prepare($tbl); + + + + $sql = "SELECT f1, f2 FROM table WHERE a=5 ORDER BY f1 DESC LIMIT 1" + if ($fields===0) $f="*"; + else + { + + } + }*/ + /***************** * custom queries * @@ -275,4 +293,17 @@ class LE_MYSQL return $this->query($s, false, ['val' => $v]); } + private function gen_f($f="*") + { + if (trim($f)=="*" || $f===0 || $f===false) return "*"; + $f = explode(',',$f); + $cnt = count($f); + + for($i=0;$i<$cnt;$i++) $f[$i] = '`'.trim($f[$i]).'`'; + + return implode(', ',$f); + + + } + } \ No newline at end of file