Exception:Array
(
[message] => Unable to prepare statement: database is locked
SELECT namespace, `key`, value
FROM setting AS _
WHERE 1 = 1
AND _.site_id = 1
AND _.namespace = 'cookie-notice'
- SELECT namespace, `key`, value
FROM setting AS _
WHERE 1 = 1
AND _.site_id = :site_id
AND _.namespace = :namespace
- Array
(
[0] => Array
(
[file] => /home/m/mzensk9k/test.rulevoimaster.ru/public_html/storage/model/app/settingsql.sqlite.php
[line] => 303
[function] => execute
[class] => Vvveb\System\Db\Sqlite
[type] => ->
)
)
[file] => /home/m/mzensk9k/test.rulevoimaster.ru/public_html/system/db/sqlite.php
[line_no] => 421
[line] => throw new \Exception($message, $e->getCode()); // <==
[lines] => Array
(
[0] => [$parameters, $types] = $this->paramsToQmark($sql, $params, $paramTypes);
[1] =>
[2] => try {
[3] => $stmt = self::$link->prepare($sql);
[4] => } catch (\Exception $e) {
[5] => $message = $e->getMessage() . "\n" . $this->debugSql($origSql, $params, $paramTypes) . "\n - " . $origSql . "\n - " . print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1), true);
[6] =>
[7] => throw new \Exception($message, $e->getCode()); // <==
[8] => }
[9] =>
[10] => if ($stmt/* && ! empty($paramTypes)*/) {
[11] => foreach ($parameters as $key => $value) {
[12] => $bindType = match ($types[$key] ?? 's') {
[13] => 'i' => SQLITE3_INTEGER,
)
[trace] => #0 /home/m/mzensk9k/test.rulevoimaster.ru/public_html/storage/model/app/settingsql.sqlite.php(303): Vvveb\System\Db\Sqlite->execute('SELECT namespac...', Array, Array)
#1 /home/m/mzensk9k/test.rulevoimaster.ru/public_html/system/setting.php(143): Vvveb\Sql\SettingSQL->getMulti(Array)
#2 /home/m/mzensk9k/test.rulevoimaster.ru/public_html/system/functions/settings.php(36): Vvveb\System\Setting->get('cookie-notice', NULL, Array, 1)
#3 /home/m/mzensk9k/test.rulevoimaster.ru/public_html/plugins/cookie-notice/plugin.php(145): Vvveb\getSetting('cookie-notice', NULL, Array)
#4 /home/m/mzensk9k/test.rulevoimaster.ru/public_html/plugins/cookie-notice/plugin.php(335): CookieNoticePlugin->settings()
#5 /home/m/mzensk9k/test.rulevoimaster.ru/public_html/plugins/cookie-notice/plugin.php(426): CookieNoticePlugin->app()
#6 /home/m/mzensk9k/test.rulevoimaster.ru/public_html/plugins/cookie-notice/plugin.php(431): CookieNoticePlugin->__construct()
#7 /home/m/mzensk9k/test.rulevoimaster.ru/public_html/system/extensions/plugins.php(354): include('/home/m/mzensk9...')
#8 /home/m/mzensk9k/test.rulevoimaster.ru/public_html/system/core/startup.php(519): Vvveb\System\Extensions\Plugins::loadPlugins(1)
#9 /home/m/mzensk9k/test.rulevoimaster.ru/public_html/index.php(172): Vvveb\System\Core\start()
#10 {main}
[code] => Array
(
[0] =>
[2] => /**
[3] => * Vvveb
[4] => *
[5] => * Copyright (C) 2022 Ziadin Givan
[6] => *
[7] => * This program is free software: you can redistribute it and/or modify
[8] => * it under the terms of the GNU Affero General Public License as
[9] => * published by the Free Software Foundation, either version 3 of the
[10] => * License, or (at your option) any later version.
[11] => *
[12] => * This program is distributed in the hope that it will be useful,
[13] => * but WITHOUT ANY WARRANTY; without even the implied warranty of
[14] => * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
[15] => * GNU Affero General Public License for more details.
[16] => *
[17] => * You should have received a copy of the GNU Affero General Public License
[18] => * along with this program. If not, see .
[19] => *
[20] => */
[21] =>
[22] => namespace Vvveb\System\Db;
[23] =>
[24] => use Vvveb\System\Event;
[25] =>
[26] => /**
[27] => * SQLite database driver using the SQLite3 extension.
[28] => *
[29] => * Provides connection management, query execution with parameterised statements,
[30] => * result fetching, escaping, and schema introspection for SQLite databases.
[31] => */
[32] => class Sqlite extends DBDriver {
[33] => /** @var ?\SQLite3 The shared database connection (singleton per process). */
[34] => private static ?\SQLite3 $link = null;
[35] =>
[36] => /** @var int Number of rows affected by the last query. */
[37] => public int $affected_rows = 0;
[38] =>
[39] => /** @var int|bool Number of rows returned by the last query, or 0 if not applicable. */
[40] => public int|bool $num_rows = 0;
[41] =>
[42] => /** @var ?int The row ID of the last inserted row, or null if none. */
[43] => public ?int $insert_id = null;
[44] =>
[45] => /** @var string Table name prefix. */
[46] => public string $prefix = ''; //'vv_';
[47] =>
[48] => /** @var string Identifier quote character for SQLite. */
[49] => public string $quote = '"';
[50] =>
[51] => /**
[52] => * Get the SQLite library version number.
[53] => *
[54] => * @return int|false The version number (e.g. 3039000), or false if not connected.
[55] => */
[56] => public static function version(): int|false {
[57] => if (self :: $link) {
[58] => return \SQLite3::version()['versionNumber'] ?? false;
[59] => }
[60] =>
[61] => return false;
[62] => }
[63] =>
[64] => /**
[65] => * Get the SQLite library version string.
[66] => *
[67] => * @return string|false The version string (e.g. '3.39.0'), or false if not connected.
[68] => */
[69] => public static function info(): string|false {
[70] => if (self :: $link) {
[71] => return \SQLite3::version()['versionString'] ?? false;
[72] => }
[73] =>
[74] => return false;
[75] => }
[76] =>
[77] => /**
[78] => * Get the error message from the last SQLite operation.
[79] => *
[80] => * @return string The error message, or empty string if not connected.
[81] => */
[82] => public function error(): string {
[83] => if (self :: $link) {
[84] => return self :: $link->lastErrorMsg();
[85] => }
[86] =>
[87] => return '';
[88] => }
[89] =>
[90] => /**
[91] => * Get the error code from the last SQLite operation.
[92] => *
[93] => * @return int The error code, or 0 if not connected.
[94] => */
[95] => public function errorCode(): int {
[96] => if (self :: $link) {
[97] => return self :: $link->lastErrorCode();
[98] => }
[99] =>
[100] => return 0;
[101] => }
[102] =>
[103] => /**
[104] => * Pass through the statement result unchanged.
[105] => *
[106] => * @param mixed $stmt The statement result.
[107] => *
[108] => * @return mixed The same statement result.
[109] => */
[110] => public function get_result(mixed $stmt): mixed {
[111] => return $stmt;
[112] => }
[113] =>
[114] => public function __construct() {
[115] => //return $this->connect($host, $dbname, $user, $pass, $port, $prefix);
[116] => }
[117] =>
[118] => /**
[119] => * Connect to the SQLite database.
[120] => *
[121] => * Uses a singleton pattern — returns the existing connection if already open.
[122] => * Enables exceptions for error handling.
[123] => *
[124] => * @param string $filename The SQLite database file path.
[125] => * @param string $dbname Database name (unused for SQLite).
[126] => * @param string $user Database user (unused for SQLite).
[127] => * @param string $pass Database password (unused for SQLite).
[128] => * @param ?string $port Port (unused for SQLite).
[129] => * @param string $prefix Table name prefix.
[130] => *
[131] => * @throws \Exception On connection failure.
[132] => *
[133] => * @return \SQLite3 The database connection.
[134] => */
[135] => public function connect(string $filename = DB_HOST, string $dbname = DB_NAME, string $user = DB_USER, string $pass = DB_PASS, ?string $port = null, string $prefix = DB_PREFIX): \SQLite3 {
[136] => if (self :: $link) {
[137] => return self :: $link;
[138] => }
[139] =>
[140] => $this->prefix = $prefix;
[141] =>
[142] => try {
[143] => self :: $link = new \SQLite3($filename); //, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE);
[144] => } catch (\Exception $e) {
[145] => $errorMessage = str_replace($pass, '*****', $e->getMessage());
[146] =>
[147] => throw new \Exception($errorMessage, $e->getCode());
[148] => }
[149] =>
[150] => self :: $link->enableExceptions(true);
[151] =>
[152] => return self :: $link;
[153] => }
[154] =>
[155] => /**
[156] => * Get all columns for a table used for sanitizing input.
[157] => *
[158] => * @param string $tableName The table name to introspect.
[159] => * @param bool $comment Whether to include column comments (unused for SQLite).
[160] => *
[161] => * @return array|false
[162] => * Associative array keyed by column name, or false on failure.
[163] => */
[164] => public function getColumnsMeta(string $tableName, bool $comment = false): array|false {
[165] => $sql =
[166] => "SELECT type as t, name, dflt_value as d, `notnull` as n FROM pragma_table_info('$tableName');";
[167] =>
[168] => if ($result = $this->query($sql)) {
[169] => $columns = [];
[170] =>
[171] => while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
[172] => $columns[$row['name']] = $row;
[173] => }
[174] =>
[175] => // free result set
[176] => $result->finalize();
[177] =>
[178] => return $columns;
[179] => }
[180] =>
[181] => return false;
[182] => }
[183] =>
[184] => /**
[185] => * Get all table names in the database.
[186] => *
[187] => * @param string $db The database name (unused for SQLite — reads sqlite_master).
[188] => *
[189] => * @return array|false List of table names, or false on failure.
[190] => */
[191] => public function getTableNames(string $db = DB_NAME): array|false {
[192] => $sql = "SELECT name FROM sqlite_master WHERE type ='table' AND name NOT LIKE 'sqlite_%' AND name NOT LIKE '%_search%' ORDER BY name";
[193] =>
[194] => if ($result = $this->query($sql)) {
[195] => $names = [];
[196] =>
[197] => while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
[198] => //$names[] = $row;
[199] => $names[] = $row['name'];
[200] => }
[201] =>
[202] => // free result set
[203] => $result->finalize();
[204] =>
[205] => return $names;
[206] => }
[207] =>
[208] => return false;
[209] => }
[210] =>
[211] => /**
[212] => * Escape a value for safe inclusion in a SQL query.
[213] => *
[214] => * Strings are escaped with SQLite3::escapeString. Null values become 'null'.
[215] => * All other types are returned as-is.
[216] => *
[217] => * @param mixed $string The value to escape.
[218] => *
[219] => * @return mixed The escaped value.
[220] => */
[221] => public function escape(mixed $string): mixed {
[222] => if (is_string($string)) {
[223] => return self :: $link->escapeString($string);
[224] => }
[225] =>
[226] => if (is_null($string)) {
[227] => return 'null';
[228] => }
[229] =>
[230] => return $string;
[231] => }
[232] =>
[233] => /**
[234] => * Escape a string value for use in a SQL literal.
[235] => *
[236] => * @param string $string The string to escape.
[237] => *
[238] => * @return string The escaped string.
[239] => */
[240] => public function escapeLiteral(string $string): string {
[241] => return $this->escape($string);
[242] => }
[243] =>
[244] => /**
[245] => * Fetch a single scalar value from a result.
[246] => *
[247] => * @param \SQLite3Result $result The query result.
[248] => *
[249] => * @return mixed The first column value, or null if no row or the value is null.
[250] => */
[251] => public function fetchOne(\SQLite3Result $result): mixed {
[252] => return $result->fetchArray(SQLITE3_NUM)[0] ?? null;
[253] => }
[254] =>
[255] => /**
[256] => * Fetch a single row from a result.
[257] => *
[258] => * @param \SQLite3Result $result The query result.
[259] => *
[260] => * @return array|false The row as an associative array, or false if no results.
[261] => */
[262] => public function fetchArray(\SQLite3Result $result): array|false {
[263] => return $result->fetchArray(SQLITE3_ASSOC);
[264] => }
[265] =>
[266] => /**
[267] => * Fetch all rows from a result.
[268] => *
[269] => * @param \SQLite3Result $result The query result.
[270] => *
[271] => * @return array> All result rows.
[272] => */
[273] => public function fetchAll(\SQLite3Result $result): array {
[274] => $return = [];
[275] =>
[276] => while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
[277] => $return[] = $row;
[278] => }
[279] =>
[280] => return $return;
[281] => }
[282] =>
[283] => /**
[284] => * Execute a raw SQL query.
[285] => *
[286] => * Automatically connects if not connected. Updates affected_rows, insert_id,
[287] => * and num_rows on success.
[288] => *
[289] => * @param string $sql The SQL query to execute.
[290] => *
[291] => * @throws \Exception On query failure.
[292] => *
[293] => * @return \SQLite3Result|false The query result, or false on failure.
[294] => */
[295] => public function query(string $sql): \SQLite3Result|false {
[296] => if (!self :: $link) {
[297] => $this->connect();
[298] => }
[299] =>
[300] => $result = false;
[301] =>
[302] => try {
[303] => $result = self :: $link->query($sql);
[304] =>
[305] => if (LOG_SQL_QUERIES) {
[306] => error_log($sql);
[307] => }
[308] =>
[309] => if ($result) {
[310] => $this->affected_rows = self :: $link->changes();
[311] => $this->insert_id = self :: $link->lastInsertRowID();
[312] => $this->num_rows = $result->numColumns() && $result->columnType(0) != SQLITE3_NULL;
[313] => //$result->finalize();
[314] => } else {
[315] => $message = $this->error() . "\n" . $sql . "\n - " . print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1), true);
[316] =>
[317] => throw new \Exception($message, $this->errorCode());
[318] => }
[319] => } catch (\Exception $e) {
[320] => $message = $e->getMessage() . "\n$sql\n" . print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1), true);
[321] =>
[322] => throw new \Exception($message, $e->getCode());
[323] => }
[324] =>
[325] => return $result;
[326] => }
[327] =>
[328] => /**
[329] => * Execute multiple SQL statements by splitting on semicolons.
[330] => *
[331] => * @param string $sql The SQL statements to execute (semicolon-separated).
[332] => *
[333] => * @throws \Exception On any statement failure.
[334] => *
[335] => * @return array Array of results from each statement.
[336] => */
[337] => public function multi_query(string $sql): array {
[338] => $results = [];
[339] =>
[340] => $queries = preg_split('/;\n/', $sql);
[341] =>
[342] => foreach ($queries as $query) {
[343] => if (empty(trim($query))) {
[344] => continue;
[345] => }
[346] =>
[347] => if (LOG_SQL_QUERIES) {
[348] => error_log($sql);
[349] => }
[350] =>
[351] => try {
[352] => $result = self :: $link->query("$query;");
[353] =>
[354] => if ($result) {
[355] => $this->affected_rows = self :: $link->changes();
[356] => $this->insert_id = self :: $link->lastInsertRowID();
[357] => $this->num_rows = $result->numColumns() && $result->columnType(0) != SQLITE3_NULL;
[358] => //$result->finalize();
[359] => } else {
[360] => $message = $this->error() . "\n" . $sql . "\n - " . print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1), true);
[361] =>
[362] => throw new \Exception($message, $this->errorCode());
[363] => }
[364] =>
[365] => $results[] = $result;
[366] => } catch (\Exception $e) {
[367] => $message = $e->getMessage() . "\n$sql\n" . print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1), true);
[368] =>
[369] => throw new \Exception($message, $e->getCode());
[370] => }
[371] => }
[372] =>
[373] => return $results;
[374] => }
[375] =>
[376] => /**
[377] => * Close the database connection.
[378] => *
[379] => * @return bool|null True on success, null if not connected.
[380] => */
[381] => public function close(): ?bool {
[382] => if (self :: $link) {
[383] => return self :: $link->close();
[384] => }
[385] =>
[386] => return null;
[387] => }
[388] =>
[389] => /**
[390] => * Prepare and execute a parameterised query.
[391] => *
[392] => * Fires an Event::trigger hook before execution. Converts named parameters
[393] => * to positional ? placeholders, binds values with appropriate SQLite3 type
[394] => * constants, and executes the statement. Updates affected_rows, insert_id,
[395] => * and num_rows on success.
[396] => *
[397] => * @param string $sql The SQL query with :named parameters.
[398] => * @param array $params Named parameter values.
[399] => * @param array $paramTypes Optional explicit type overrides.
[400] => *
[401] => * @throws \Exception On prepare or execute failure.
[402] => *
[403] => * @return \SQLite3Result|false|null The query result, false, or null on failure.
[404] => */
[405] => public function execute(string $sql, array $params = [], array $paramTypes = []): \SQLite3Result|false|null {
[406] => [$sql, $params] = Event::trigger(__CLASS__, __FUNCTION__, $sql, $params);
[407] => //save orig sql for debugging info
[408] => $origSql = $sql;
[409] =>
[410] => if (!self :: $link) {
[411] => $this->connect();
[412] => }
[413] =>
[414] => [$parameters, $types] = $this->paramsToQmark($sql, $params, $paramTypes);
[415] =>
[416] => try {
[417] => $stmt = self::$link->prepare($sql);
[418] => } catch (\Exception $e) {
[419] => $message = $e->getMessage() . "\n" . $this->debugSql($origSql, $params, $paramTypes) . "\n - " . $origSql . "\n - " . print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1), true);
[420] =>
[421] => throw new \Exception($message, $e->getCode()); // <==
[422] => }
[423] =>
[424] => if ($stmt/* && ! empty($paramTypes)*/) {
[425] => foreach ($parameters as $key => $value) {
[426] => $bindType = match ($types[$key] ?? 's') {
[427] => 'i' => SQLITE3_INTEGER,
[428] => 'd' => SQLITE3_FLOAT,
[429] => 'b' => SQLITE3_BLOB,
[430] => default => SQLITE3_TEXT,
[431] => };
[432] => $index = (int)$key + 1;
[433] => $stmt->bindValue($index, $value, $bindType);
[434] => }
[435] => } else {
[436] => if (DEBUG) {
[437] => error_log((self :: $link->lastErrorMsg ?? '') . ' ' . $this->debugSql($origSql, $params, $paramTypes));
[438] => }
[439] => }
[440] =>
[441] => if (LOG_SQL_QUERIES) {
[442] => error_log($this->debugSql($origSql, $params, $paramTypes));
[443] => }
[444] =>
[445] => if ($stmt) {
[446] => $result = null;
[447] =>
[448] => try {
[449] => if ($result = $stmt->execute()) {
[450] => $this->affected_rows = self :: $link->changes();
[451] => $this->insert_id = self :: $link->lastInsertRowID();
[452] => $this->num_rows = $result->numColumns() && $result->columnType(0) != SQLITE3_NULL;
[453] =>
[454] => return $result;
[455] => } else {
[456] => error_log(print_r($result, true));
[457] => error_log($this->debugSql($sql, $params, $paramTypes));
[458] => }
[459] => } catch (\Exception $e) {
[460] => $message = $e->getMessage() . "\n" . $origSql . "\n" . $this->debugSql($origSql, $params, $paramTypes) . "\n" . print_r($parameters, true) . $types . "\n" . print_r(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1), true);
[461] =>
[462] => throw new \Exception($message, $e->getCode());
[463] => }
[464] => } else {
[465] => error_log(print_r($stmt, true));
[466] => error_log($this->debugSql($origSql, $params, $paramTypes));
[467] => }
[468] =>
[469] => return $stmt;
[470] => }
[471] => }
)
)