givanz / Vvveb

Powerful and easy to use cms to build websites, blogs or ecommerce stores.
https://www.vvveb.com
GNU Affero General Public License v3.0
239 stars 49 forks source link

When installing an error is shown in PHP #138

Open DEV-Devound opened 1 week ago

DEV-Devound commented 1 week ago

php cli.php install module=index host=127.0.0.1 user=root password=1234 database=vvveb admin[email]=admin@vvveb.com admin[password]=admin engine=mysqli

Fatal error: Uncaught Error: Class "DomDocument" not found in /home/kali/Documents/Code/Vvveb/system/vtpl/vtpl.php:145 Stack trace:

0 /home/kali/Documents/Code/Vvveb/system/core/view.php(106): Vtpl->__construct()

1 /home/kali/Documents/Code/Vvveb/system/core/frontcontroller.php(122): Vvveb\System\Core\View->__construct()

2 /home/kali/Documents/Code/Vvveb/system/core/startup.php(246): Vvveb\System\Core\FrontController::notFound()

3 [internal function]: Vvveb\System\Core\exceptionHandler()

4 {main}

thrown in /home/kali/Documents/Code/Vvveb/system/vtpl/vtpl.php on line 145

givanz commented 1 week ago

Your php is missing dom extension, you can enable it from your server cpanel or install it with something like

sudo apt-get install php-dom
DEV-Devound commented 1 week ago

Your php is missing dom extension, you can enable it from your server cpanel or install it with something like

sudo apt-get install php-dom

php cli.php install module=index host=127.0.0.1 user=root password=1234 database=vvveb admin[dev.devound@gmail.com]=admin@vvveb.com admin[1234]=admin engine=mysqli

{ "message": "Connection refused", "file": "\/home\/kali\/Documents\/vvveb\/system\/db\/mysqli.php", "line_no": 144, "line": "\t\t\tthrow new \Exception($errorMessage, $e->getCode());\t \/\/ <==\n", "lines": [ "\n", "\t\ttry {\n", "\t\t\tself :: $link = new \Mysqli(\/'p:' . \/$host, $user, $pass, $dbname, $port);\n", "\t\t\t\/\/self :: $link = $this;\n", "\t\t} catch (\mysqli_sql_exception $e) {\n", "\t\t\t$errorMessage = str_replace($pass,'', $e->getMessage());\n", "\n", "\t\t\tthrow new \Exception($errorMessage, $e->getCode());\t \/\/ <==\n", "\t\t}\n", "\n", "\t\t\/\/ check if a connection established\n", "\t\tif (\mysqli_connect_errno()) {\n", "\t\t\t$error = mysqli_connect_error();\n", "\t\t\t$errorMessage = str_replace($pass,'', $error);\n" ], "trace": "#0 \/home\/kali\/Documents\/vvveb\/system\/db.php(37): Vvveb\System\Db\Mysqli->construct()\n#1 \/home\/kali\/Documents\/vvveb\/system\/sqlp\/sqlp.php(50): Vvveb\System\Db::getInstance()\n#2 \/home\/kali\/Documents\/vvveb\/system\/core\/startup.php(93): Vvveb\System\Sqlp\Sqlp->construct()\n#3 \/home\/kali\/Documents\/vvveb\/system\/core\/startup.php(180): Vvveb\System\Core\regenerateSQL()\n#4 \/home\/kali\/Documents\/vvveb\/system\/user\/admin.php(93): Vvveb\System\Core\autoload()\n#5 \/home\/kali\/Documents\/vvveb\/install\/controller\/index.php(256): Vvveb\System\User\Admin::update()\n#6 \/home\/kali\/Documents\/vvveb\/install\/controller\/index.php(211): Vvveb\Controller\Index->install()\n#7 [internal function]: Vvveb\Controller\Index->index()\n#8 \/home\/kali\/Documents\/vvveb\/system\/core\/frontcontroller.php(229): call_user_func()\n#9 \/home\/kali\/Documents\/vvveb\/system\/core\/frontcontroller.php(298): Vvveb\System\Core\FrontController::call()\n#10 \/home\/kali\/Documents\/vvveb\/system\/core\/frontcontroller.php(362): Vvveb\System\Core\FrontController::redirect()\n#11 \/home\/kali\/Documents\/vvveb\/system\/core\/startup.php(363): Vvveb\System\Core\FrontController::dispatch()\n#12 \/home\/kali\/Documents\/vvveb\/cli.php(145): Vvveb\System\Core\start()\n#13 {main}", "code": [ "<?php\n", "\n", "\/\n", " Vvveb\n", " \n", " Copyright (C) 2022 Ziadin Givan\n", " \n", " This program is free software: you can redistribute it and\/or modify\n", " it under the terms of the GNU Affero General Public License as\n", " published by the Free Software Foundation, either version 3 of the\n", " License, or (at your option) any later version.\n", " \n", " This program is distributed in the hope that it will be useful,\n", " but WITHOUT ANY WARRANTY; without even the implied warranty of\n", " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n", " GNU Affero General Public License for more details.\n", " \n", " You should have received a copy of the GNU Affero General Public License\n", " along with this program. If not, see <https:\/\/www.gnu.org\/licenses\/>.\n", " \n", " \/\n", "\n", "namespace Vvveb\System\Db;\n", "\n", "use Vvveb\System\Event;\n", "\n", "\/\n", " Define and use mysqli_result if native is missing\n", " \/\n", "class mysqli_result {\n", "\tprivate $stmt;\n", "\n", "\tprivate $meta;\n", "\n", "\tpublic function __construct($stmt) {\n", "\t\t$this->stmt = $stmt;\n", "\t}\n", "\n", "\tpublic function fetch_all() {\n", "\t\treturn $this->fetch_assoc();\n", "\t}\n", "\n", "\tpublic function fetch_array($resulttype) {\n", "\t\treturn $this->fetch_assoc();\n", "\t}\n", "\n", "\tpublic function fetch_assoc() {\n", "\t\t\/\/$meta = $this->stmt->store_result();\n", "\t\t$meta = $this->stmt->result_metadata();\n", "\t\t$row = [];\n", "\n", "\t\twhile ($field = $meta->fetch_field()) {\n", "\t\t\t$params[] = &$row[$field->name];\n", "\t\t}\n", "\n", "\t\tcall_user_func_array([$this->stmt, 'bind_result'], $params);\n", "\n", "\t\twhile ($this->stmt->fetch()) {\n", "\t\t\t$c = [];\n", "\n", "\t\t\tforeach ($row as $key => $val) {\n", "\t\t\t\t$c[$key] = $val;\n", "\t\t\t}\n", "\t\t\t$result[] = $c;\n", "\t\t}\n", "\n", "\t\t\/\/$this->stmt->free_result();\n", "\t\t\/\/$this->stmt->close();\n", "\n", "\t\treturn $result;\n", "\t}\n", "\n", "\tpublic function fetch_field() {\n", "\t}\n", "\n", "\tpublic function fetch_fields() {\n", "\t}\n", "\n", "\tpublic function fetchRow() {\n", "\t\treturn $this->fetch_assoc();\n", "\t}\n", "}\n", "\n", "class Mysqli extends DBDriver {\n", "\tprivate static $link = null;\n", "\n", "\t\/\/public $error;\n", "\n", "\tprivate $stmt;\n", "\n", "\tpublic $affected_rows = 0;\n", "\n", "\tpublic $insertid = null;\n", "\n", "\tpublic $quote = '`';\n", "\n", "\tpublic $prefix = ''; \/\/'vv';\n", "\n", "\tpublic static function version() {\n", "\t\tif (self :: $link) {\n", "\t\t\treturn mysqli_get_server_version(self :: $link);\n", "\t\t}\n", "\t}\n", "\n", "\tpublic static function info() {\n", "\t\tif (self :: $link) {\n", "\t\t\treturn mysqli_get_server_info(self :: $link);\n", "\t\t}\n", "\t}\n", "\n", "\tpublic function error() {\n", "\t\tif (self :: $link) {\n", "\t\t\treturn self :: $link->error;\n", "\t\t}\n", "\t}\n", "\n", "\tpublic function errorCode() {\n", "\t\tif (self :: $link) {\n", "\t\t\treturn self :: $link->errno;\n", "\t\t}\n", "\t}\n", "\n", "\tpublic function get_result($stmt) {\n", "\t\t$result = new mysqli_result($stmt);\n", "\n", "\t\treturn $result;\n", "\t}\n", "\n", "\tpublic function __construct($host = DB_HOST, $dbname = DB_NAME, $user = DB_USER, $pass = DB_PASS, $port = DB_PORT, $prefix = DB_PREFIX) {\n", "\t\t\/\/mysqli_report(MYSQLI_REPORT_OFF);\n", "\t\t\/\/connect to database\n", "\t\tif (self :: $link) {\n", "\t\t\treturn self :: $link;\n", "\t\t}\n", "\t\t$this->prefix = $prefix;\n", "\n", "\t\t\mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);\n", "\n", "\t\ttry {\n", "\t\t\tself :: $link = new \Mysqli(\/'p:' . \/$host, $user, $pass, $dbname, $port);\n", "\t\t\t\/\/self :: $link = $this;\n", "\t\t} catch (\mysqli_sql_exception $e) {\n", "\t\t\t$errorMessage = str_replace($pass,'**', $e->getMessage());\n", "\n", "\t\t\tthrow new \Exception($errorMessage, $e->getCode());\t \/\/ <==\n", "\t\t}\n", "\n", "\t\t\/\/ check if a connection established\n", "\t\tif (\mysqli_connect_errno()) {\n", "\t\t\t$error = mysqli_connect_error();\n", "\t\t\t$errorMessage = str_replace($pass,'', $error);\n", "\n", "\t\t\tthrow new \Exception($errorMessage, mysqli_connect_errno());\n", "\t\t}\n", "\n", "\t\tif ((! self :: $link instanceof \MySQLi)) {\n", "\t\t\tthrow new \Exception('Mysqli not an object', mysqli_connect_errno());\n", "\t\t}\n", "\n", "\t\treturn self :: $link;\n", "\t}\n", "\n", "\t\/\n", "\t Get all columns for a table used for sanitizing input\n", "\t \/\n", "\tfunction getColumnsMeta($tableName) {\n", "\t\t$sql =\n", "\t\t'SELECT COLUMN_NAME as name, COLUMN_DEFAULT as d, IS_NULLABLE as n, DATA_TYPE as t, EXTRA as e\n", "\t\tFROM INFORMATION_SCHEMA.COLUMNS \n", "\t\tWHERE TABLE_SCHEMA= \"' . DB_NAME . '\" \n", "\t\t\tAND TABLE_NAME=\"' . $tableName . '\"';\n", "\n", "\t\tif ($result = $this->query($sql)) {\n", "\t\t\t\/\/$columns = $result->fetch_all(MYSQLI_ASSOC);\n", "\t\t\t$columns = [];\n", "\n", "\t\t\twhile ($row = $result->fetch_assoc()) {\n", "\t\t\t\t$columns[] = $row;\n", "\t\t\t}\n", "\n", "\t\t\t\/ free result set \/\n", "\t\t\t$result->close();\n", "\n", "\t\t\treturn $columns;\n", "\t\t} else {\n", "\t\t}\n", "\n", "\t\treturn false;\n", "\t}\n", "\n", "\tfunction getTableNames($db = DB_NAME) {\n", "\t\t$sql =\"SELECT table_name as name\n", "\t\t\tFROM information_schema.tables \n", "\t\t\tWHERE table_schema = '$db' ORDER BY table_name\";\n", "\n", "\t\tif ($result = $this->query($sql)) {\n", "\t\t\t\/\/$names = $result->fetch_all(MYSQLI_ASSOC);\n", "\t\t\t$names = [];\n", "\n", "\t\t\twhile ($row = $result->fetch_assoc()) {\n", "\t\t\t\t$names[] = $row['name'];\n", "\t\t\t}\n", "\n", "\t\t\t\/ free result set \/\n", "\t\t\t$result->close();\n", "\n", "\t\t\treturn $names;\n", "\t\t} else {\n", "\t\t}\n", "\n", "\t\treturn false;\n", "\t}\n", "\n", "\tpublic function select_db($db) {\n", "\t\treturn self :: $link->select_db($db);\n", "\t}\n", "\n", "\tpublic function query($sql) {\n", "\t\t$result = self :: $link->query($sql);\n", "\n", "\t\tif ($result) {\n", "\t\t\t$this->affected_rows = self :: $link->affected_rows;\n", "\t\t\t$this->insert_id = self :: $link->insert_id;\n", "\t\t}\n", "\n", "\t\treturn $result;\n", "\t}\n", "\n", "\tpublic function multi_query($sql) {\n", "\t\t$result = self :: $link->multi_query($sql);\n", "\n", "\t\tif ($result) {\n", "\t\t\t$this->affected_rows = self :: $link->affected_rows;\n", "\t\t\t$this->insert_id = self :: $link->insert_id;\n", "\t\t}\n", "\n", "\t\treturn $result;\n", "\t}\n", "\n", "\tpublic function escape($string) {\n", "\t\tif (is_string($string)) {\n", "\t\t\treturn self :: $link->real_escape_string($string);\n", "\t\t}\n", "\n", "\t\tif (is_null($string)) {\n", "\t\t\treturn 'null';\n", "\t\t}\n", "\n", "\t\treturn $string;\n", "\t}\n", "\n", "\tpublic function sqlLimit($start, $limit) {\n", "\t\treturn \"LIMIT $start, $limit\";\n", "\t}\n", "\n", "\tpublic function fetchArray($stmt) {\n", "\t\t$result = $stmt->get_result();\n", "\n", "\t\tif ($result) {\n", "\t\t\treturn $result->fetch_array(MYSQLI_ASSOC);\n", "\t\t}\n", "\n", "\t\treturn [];\n", "\t}\n", "\n", "\tpublic function fetchAll($stmt) {\n", "\t\t$result = $stmt->get_result();\n", "\n", "\t\tif ($result) {\n", "\t\t\treturn $result->fetch_all(MYSQLI_ASSOC);\n", "\t\t}\n", "\n", "\t\treturn [];\n", "\t}\n", "\n", "\tpublic function store_result() {\n", "\t\treturn self :: $link->store_result();\n", "\t}\n", "\n", "\tpublic function more_results() {\n", "\t\treturn self :: $link->more_results();\n", "\t}\n", "\n", "\tpublic function next_result() {\n", "\t\treturn self :: $link->next_result();\n", "\t}\n", "\n", "\tpublic function close() {\n", "\t\tif ((self :: $link instanceof \MySQLi)\/ && self :: $link->ping()*\/) {\n", "\t\t\treturn self :: $link->close();\n", "\t\t}\n", "\t}\n", "\n", "\t\/\/ Prepare\n", "\tpublic function execute($sql, $params = [], $paramTypes = []) {\n", "\t\tlist($sql, $params) = Event::trigger(CLASS,FUNCTION, $sql, $params);\n", "\t\t\/\/save orig sql for debugging info\n", "\t\t$origSql = $sql;\n", "\n", "\t\tlist($parameters, $types) = $this->paramsToQmark($sql, $params, $paramTypes);\n", "\n", "\t\ttry {\n", "\t\t\t$stmt = self::$link->prepare($sql);\n", "\t\t} catch (\mysqli_sql_exception $e) {\n", "\t\t\t$message = $e->getMessage() . \"\n\" . $this->debugSql($origSql, $params, $paramTypes) . \"\n - \" . $origSql;\n", "\n", "\t\t\tthrow new \Exception($message, $e->getCode());\n", "\t\t}\n", "\n", "\t\tif ($stmt && ! empty($types)) {\n", "\t\t\tarray_unshift($parameters, $types);\n", "\n", "\t\t\t\/\/hack for php 7.x bind_param \"expected to be a reference, value given\" stupid warning\n", "\t\t\t$referenceArray = [];\n", "\n", "\t\t\tforeach ($parameters as $key => $value) {\n", "\t\t\t\t$referenceArray[$key] = &$parameters[$key];\n", "\t\t\t}\n", "\n", "\t\t\t@call_user_func_array([$stmt, 'bind_param'], $referenceArray);\n", "\t\t}\n", "\n", "\t\tif (LOG_SQL_QUERIES) {\n", "\t\t\terror_log($this->debugSql($origSql, $params, $paramTypes));\n", "\t\t}\n", "\n", "\t\tif ($stmt) {\n", "\t\t\ttry {\n", "\t\t\t\tif ($stmt->execute()) {\n", "\t\t\t\t\t$this->affected_rows = self :: $link->affected_rows;\n", "\t\t\t\t\t$this->insert_id = self :: $link->insert_id;\n", "\n", "\t\t\t\t\treturn $stmt;\n", "\t\t\t\t} else {\n", "\t\t\t\t\terror_log(print_r($stmt, 1));\n", "\t\t\t\t\terror_log($this->debugSql($sql, $params, $paramTypes));\n", "\t\t\t\t}\n", "\t\t\t} catch (\mysqli_sql_exception $e) {\n", "\t\t\t\t$message = $e->getMessage() . \"\n\" . $origSql . \"\n\" . $this->debugSql($origSql, $params, $paramTypes) . \"\n\" . print_r($parameters, 1) . $types;\n", "\n", "\t\t\t\tthrow new \Exception($message, $e->getCode());\n", "\t\t\t}\n", "\t\t} else {\n", "\t\t\terror_log(print_r($stmt, 1));\n", "\t\t\terror_log($this->debugSql($origSql, $params, $paramTypes));\n", "\t\t}\n", "\n", "\t\treturn $stmt;\n", "\t}\n", "\n", "\t\/\/ Bind\n", "\tpublic function bind($param, $value, $type = null) {\n", "\t\t$this->stmt->bindValue($param, $value, $type);\n", "\t}\n", "}\n" ] }

DEV-Devound commented 1 week ago

how do i solve that?

givanz commented 1 week ago

You need to change mysql user and password to match the ones from your mysql server

php cli.php install module=index host=127.0.0.1 user=root password=your_mysql_password database=your_vvveb_database_name admin[email]=admin@vvveb.com admin[password]=admin engine=mysqli

Or you can simply use SQLite to skip database configuration

php cli.php install module=index admin[email]=admin@vvveb.com admin[password]=admin engine=sqlite
DEV-Devound commented 1 week ago

{ "message": "Class \"SQLite3\" not found", "file": "\/home\/kali\/Documents\/vvveb\/system\/db\/sqlite.php", "line_no": 80, "line": "\t\t\tself :: $link = new \SQLite3($filename); \/\/, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);\t \/\/ <==\n", "lines": [ "\n", "\tpublic function construct($filename = DB_HOST, $dbname = DB_NAME, $user = DB_USER, $pass = DB_PASS, $port = null, $prefix = DB_PREFIX) {\n", "\t\tif (self :: $link) {\n", "\t\t\treturn self :: $link;\n", "\t\t}\n", "\n", "\t\ttry {\n", "\t\t\tself :: $link = new \SQLite3($filename); \/\/, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);\t \/\/ <==\n", "\t\t} catch (\Exception $e) {\n", "\t\t\t$errorMessage = str_replace($pass,'*****', $e->getMessage());\n", "\n", "\t\t\tthrow new \Exception($errorMessage, $e->getCode());\n", "\t\t}\n", "\n" ], "trace": "#0 \/home\/kali\/Documents\/vvveb\/system\/import\/sql.php(40): Vvveb\System\Db\Sqlite->construct()\n#1 \/home\/kali\/Documents\/vvveb\/install\/controller\/index.php(154): Vvveb\System\Import\Sql->construct()\n#2 \/home\/kali\/Documents\/vvveb\/install\/controller\/index.php(208): Vvveb\Controller\Index->import()\n#3 [internal function]: Vvveb\Controller\Index->index()\n#4 \/home\/kali\/Documents\/vvveb\/system\/core\/frontcontroller.php(229): call_user_func()\n#5 \/home\/kali\/Documents\/vvveb\/system\/core\/frontcontroller.php(298): Vvveb\System\Core\FrontController::call()\n#6 \/home\/kali\/Documents\/vvveb\/system\/core\/frontcontroller.php(362): Vvveb\System\Core\FrontController::redirect()\n#7 \/home\/kali\/Documents\/vvveb\/system\/core\/startup.php(363): Vvveb\System\Core\FrontController::dispatch()\n#8 \/home\/kali\/Documents\/vvveb\/cli.php(145): Vvveb\System\Core\start()\n#9 {main}", "code": [ "<?php\n", "\n", "\/*\n", " Vvveb\n", " \n", " Copyright (C) 2022 Ziadin Givan\n", " \n", " This program is free software: you can redistribute it and\/or modify\n", " it under the terms of the GNU Affero General Public License as\n", " published by the Free Software Foundation, either version 3 of the\n", " License, or (at your option) any later version.\n", " \n", " This program is distributed in the hope that it will be useful,\n", " but WITHOUT ANY WARRANTY; without even the implied warranty of\n", " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n", " GNU Affero General Public License for more details.\n", " \n", " You should have received a copy of the GNU Affero General Public License\n", " along with this program. If not, see <https:\/\/www.gnu.org\/licenses\/>.\n", " \n", " *\/\n", "\n", "namespace Vvveb\System\Db;\n", "\n", "use Vvveb\System\Event;\n", "\n", "class Sqlite extends DBDriver {\n", "\tprivate static $link = null;\n", "\n", "\t\/\/public $error;\n", "\n", "\tprivate $stmt;\n", "\n", "\tpublic $affected_rows = 0;\n", "\n", "\tpublic $num_rows = 0;\n", "\n", "\tpublic $insertid = null;\n", "\n", "\tpublic $prefix = ''; \/\/'vv';\n", "\n", "\tpublic $quote = '`';\n", "\n", "\tpublic static function version() {\n", "\t\tif (self :: $link) {\n", "\t\t\treturn mysqli_get_server_version(self :: $link);\n", "\t\t}\n", "\t}\n", "\n", "\tpublic static function info() {\n", "\t\tif (self :: $link) {\n", "\t\t\treturn self :: $link->version();\n", "\t\t}\n", "\t}\n", "\n", "\tpublic function error() {\n", "\t\tif (self :: $link) {\n", "\t\t\treturn self :: $link->lastErrorMsg() ?? '';\n", "\t\t}\n", "\t}\n", "\n", "\tpublic function errorCode() {\n", "\t\tif (self :: $link) {\n", "\t\t\treturn self :: $link->lastErrorCode() ?? 0;\n", "\t\t}\n", "\t}\n", "\n", "\tpublic function get_result($stmt) {\n", "\t\treturn $stmt;\n", "\t\t$result = new \SQLite3Stmt($stmt);\n", "\n", "\t\treturn $result;\n", "\t}\n", "\n", "\tpublic function construct($filename = DB_HOST, $dbname = DB_NAME, $user = DB_USER, $pass = DB_PASS, $port = null, $prefix = DB_PREFIX) {\n", "\t\tif (self :: $link) {\n", "\t\t\treturn self :: $link;\n", "\t\t}\n", "\n", "\t\ttry {\n", "\t\t\tself :: $link = new \SQLite3($filename); \/\/, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);\t \/\/ <==\n", "\t\t} catch (\Exception $e) {\n", "\t\t\t$errorMessage = str_replace($pass,'****', $e->getMessage());\n", "\n", "\t\t\tthrow new \Exception($errorMessage, $e->getCode());\n", "\t\t}\n", "\n", "\t\tself :: $link->enableExceptions(true);\n", "\n", "\t\treturn self :: $link;\n", "\t}\n", "\n", "\t\/\n", "\t Get all columns for a table used for sanitizing input\n", "\t \/\n", "\tfunction getColumnsMeta($tableName) {\n", "\t\t$sql =\n", "\t\t\"SELECT type as t, name, dflt_value as d, notnull as n FROM pragma_table_info('$tableName');\";\n", "\n", "\t\tif ($result = $this->query($sql)) {\n", "\t\t\t\/\/$columns = $result->fetch_all(MYSQLI_ASSOC);\n", "\t\t\t$columns = [];\n", "\n", "\t\t\twhile ($row = $result->fetchArray(SQLITE3_ASSOC)) {\n", "\t\t\t\t$columns[] = $row;\n", "\t\t\t}\n", "\n", "\t\t\t\/ free result set \/\n", "\t\t\t$result->finalize();\n", "\n", "\t\t\treturn $columns;\n", "\t\t} else {\n", "\t\t}\n", "\n", "\t\treturn false;\n", "\t}\n", "\n", "\tfunction getTableNames($db = DB_NAME) {\n", "\t\t$sql = \"SELECT name FROM sqlitemaster WHERE type ='table' AND name NOT LIKE 'sqlite%' AND name NOT LIKE '%_search%' ORDER BY name\";\n", "\n", "\t\tif ($result = $this->query($sql)) {\n", "\t\t\t\/\/$columns = $result->fetch_all(MYSQLI_ASSOC);\n", "\t\t\t$names = [];\n", "\n", "\t\t\twhile ($row = $result->fetchArray(SQLITE3_ASSOC)) {\n", "\t\t\t\t\/\/$names[] = $row;\n", "\t\t\t\t$names[] = $row['name'];\n", "\t\t\t}\n", "\n", "\t\t\t\/ free result set \/\n", "\t\t\t$result->finalize();\n", "\n", "\t\t\treturn $names;\n", "\t\t} else {\n", "\t\t}\n", "\n", "\t\treturn false;\n", "\t}\n", "\n", "\tpublic function escape($string) {\n", "\t\tif (is_string($string)) {\n", "\t\t\treturn self :: $link->escapeString($string);\n", "\t\t}\n", "\n", "\t\tif (is_null($string)) {\n", "\t\t\treturn 'null';\n", "\t\t}\n", "\n", "\t\treturn $string;\n", "\t}\n", "\n", "\tpublic function sqlLimit($start, $limit) {\n", "\t\treturn \"LIMIT $start, $limit\";\n", "\t}\n", "\n", "\tpublic function fetchOne($result) {\n", "\t\t$return = false;\n", "\n", "\t\tif ($result) {\n", "\t\t\t$return = $result->fetchArray(SQLITE3_NUM)[0] ?? null;\n", "\t\t}\n", "\n", "\t\treturn $return;\n", "\t}\n", "\n", "\tpublic function fetchArray($result) {\n", "\t\t$return = false;\n", "\n", "\t\tif ($result) {\n", "\t\t\t$return = $result->fetchArray(SQLITE3_ASSOC);\n", "\t\t}\n", "\n", "\t\treturn $return;\n", "\t}\n", "\n", "\tpublic function fetchAll($result) {\n", "\t\t$return = [];\n", "\n", "\t\tif ($result) {\n", "\t\t\twhile ($row = $result->fetchArray(SQLITE3_ASSOC)) {\n", "\t\t\t\t$return[] = $row;\n", "\t\t\t}\n", "\t\t}\n", "\n", "\t\treturn $return;\n", "\t}\n", "\n", "\tpublic function query($sql) {\n", "\t\t$result = false;\n", "\n", "\t\ttry {\n", "\t\t\t$result = self :: $link->query($sql);\n", "\n", "\t\t\tif ($result) {\n", "\t\t\t\t$this->affected_rows = self :: $link->changes();\n", "\t\t\t\t$this->insert_id = self :: $link->lastInsertRowID();\n", "\t\t\t\t$this->num_rows = $result->numColumns() && $result->columnType(0) != SQLITE3_NULL;\n", "\t\t\t\/\/$result->finalize();\n", "\t\t\t} else {\n", "\t\t\t\tthrow new \Exception($this->error(), $this->errorCode());\n", "\t\t\t}\n", "\t\t} catch (\Exception $e) {\n", "\t\t\t$message = $e->getMessage() . \"\n$sql\n\";\n", "\n", "\t\t\tthrow new \Exception($message, $e->getCode());\n", "\t\t}\n", "\n", "\t\treturn $result;\n", "\t}\n", "\n", "\tpublic function multi_query($sql) {\n", "\t\t$result = self :: $link->query($sql);\n", "\n", "\t\tif ($result) {\n", "\t\t\t$this->affected_rows = self :: $link->changes();\n", "\t\t\t$this->insert_id = self :: $link->lastInsertRowID();\n", "\t\t\t$this->num_rows = $result->numColumns() && $result->columnType(0) != SQLITE3_NULL;\n", "\t\t}\n", "\n", "\t\treturn $result;\n", "\t}\n", "\n", "\tpublic function close() {\n", "\t\treturn self :: $link->close();\n", "\t}\n", "\n", "\t\/\/ Prepare\n", "\tpublic function execute($sql, $params = [], $paramTypes = []) {\n", "\t\tlist($sql, $params) = Event::trigger(CLASS,FUNCTION, $sql, $params);\n", "\t\t\/\/save orig sql for debugging info\n", "\t\t$origSql = $sql;\n", "\n", "\t\tlist($parameters, $types) = $this->paramsToQmark($sql, $params, $paramTypes);\n", "\n", "\t\ttry {\n", "\t\t\t$stmt = self::$link->prepare($sql);\n", "\t\t} catch (\Exception $e) {\n", "\t\t\t$message = $e->getMessage() . \"\n\" . $this->debugSql($origSql, $params, $paramTypes) . \"\n - \" . $origSql;\n", "\n", "\t\t\tthrow new \Exception($message, $e->getCode());\n", "\t\t}\n", "\t\tif ($stmt\/ && ! empty($paramTypes)\/) {\n", "\t\t\tforeach ($parameters as $key => $value) {\n", "\t\t\t\t$type = $types[$key] ?? 's';\n", "\t\t\t\t$type = ($type == 'i') ? SQLITE3_INTEGER : SQLITE3_TEXT;\n", "\t\t\t\t$index = (int)$key + 1;\n", "\t\t\t\t$stmt->bindValue($index, $value, $type);\n", "\t\t\t}\n", "\t\t} else {\n", "\t\t\tif (DEBUG) {\n", "\t\t\t\terror_log((self :: $link->lastErrorMsg ?? '') . ' ' . $this->debugSql($origSql, $params, $paramTypes));\n", "\t\t\t}\n", "\t\t}\n", "\n", "\t\tif (LOG_SQL_QUERIES) {\n", "\t\t\terror_log($this->debugSql($origSql, $params, $paramTypes));\n", "\t\t}\n", "\n", "\t\tif ($stmt) {\n", "\t\t\ttry {\n", "\t\t\t\tif ($result = $stmt->execute()) {\n", "\t\t\t\t\t$this->affected_rows = self :: $link->changes();\n", "\t\t\t\t\t$this->insert_id = self :: $link->lastInsertRowID();\n", "\t\t\t\t\t$this->num_rows = $result->numColumns() && $result->columnType(0) != SQLITE3_NULL;\n", "\n", "\t\t\t\t\treturn $result;\n", "\t\t\t\t} else {\n", "\t\t\t\t\terror_log(print_r($result, 1));\n", "\t\t\t\t\terror_log($this->debugSql($sql, $params, $paramTypes));\n", "\t\t\t\t}\n", "\t\t\t} catch (\Exception $e) {\n", "\t\t\t\t$message = $e->getMessage() . \"\n\" . $origSql . \"\n\" . $this->debugSql($origSql, $params, $paramTypes) . \"\n\" . print_r($parameters, 1) . $types;\n", "\n", "\t\t\t\tthrow new \Exception($message, $e->getCode());\n", "\t\t\t}\n", "\t\t} else {\n", "\t\t\terror_log(print_r($stmt, 1));\n", "\t\t\terror_log($this->debugSql($origSql, $params, $paramTypes));\n", "\t\t}\n", "\n", "\t\treturn $stmt;\n", "\t}\n", "\n", "\t\/\/ Bind\n", "\tpublic function bind($param, $value, $type = null) {\n", "\t\t$this->stmt->bindValue($param, $value, $type);\n", "\t}\n", "}\n" ] }
but i have SQLITE3 installed

givanz commented 1 week ago

Check your php.ini, probably the sqlite3 extension is not enabled.

https://www.php.net/manual/en/sqlite3.installation.php

Windows users must enable php_sqlite3.dll in order to use this extension. This DLL is included with Windows distributions of PHP.

DEV-Devound commented 1 week ago

im on linux, also which php.ini? because this repo has a php.ini

givanz commented 1 week ago

If you are on linux then you can try to install the extension

sudo apt-get install php-sqlite3

The included php.ini has some recommended defaults and is used to increase some limits when using docker.

You can check the path of php.ini that is loaded by php with

php -i | fgrep php.ini

Or open a simple php file with

<?php
phpinfo();