KD2 Framework  Check-in [d7b11990e4]

Overview
Comment:Allow to create SQLite3 collations
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 7.3
Files: files | file ages | folders
SHA1: d7b11990e45e54c7b03f52b498b35dee9603b20c
User & Date: bohwaz on 2022-01-11 21:44:38
Other Links: branch diff | manifest | tags
Context
2022-01-20
23:45
Brindille: Remove whitespaces check-in: 81ac71f257 user: bohwaz tags: 7.3
2022-01-11
21:44
Allow to create SQLite3 collations check-in: d7b11990e4 user: bohwaz tags: 7.3
21:43
SVG charts: change line colors to work with dark backgrounds check-in: a804669450 user: bohwaz tags: 7.3
Changes

Modified src/lib/KD2/DB/DB.php from [205420ea08] to [3bb05e5da9].

63
64
65
66
67
68
69



70
71
72
73
74
75
76
	protected $pdo;

	protected $sqlite_functions = [
		'base64_encode'      => 'base64_encode',
		'rank'               => [__CLASS__, 'sqlite_rank'],
		'haversine_distance' => [__CLASS__, 'sqlite_haversine'],
	];




	/**
	 * Class construct, expects a driver configuration
	 * @param array $driver Driver configurtaion
	 */
	public function __construct(string $name, array $params)
	{







>
>
>







63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
	protected $pdo;

	protected $sqlite_functions = [
		'base64_encode'      => 'base64_encode',
		'rank'               => [__CLASS__, 'sqlite_rank'],
		'haversine_distance' => [__CLASS__, 'sqlite_haversine'],
	];

	protected $sqlite_collations = [
	];

	/**
	 * Class construct, expects a driver configuration
	 * @param array $driver Driver configurtaion
	 */
	public function __construct(string $name, array $params)
	{

Modified src/lib/KD2/DB/SQLite3.php from [b6decac842] to [75b79a0e7b].

48
49
50
51
52
53
54

55


56
57
58
59
60
61
62
	 */
	protected $flags = null;

	const DATE_FORMAT = 'Y-m-d H:i:s';

	public function close(): void
	{

		$this->db->close();


		$this->db = null;
	}

	public function __construct(string $driver, array $params)
	{
		if (!defined('\SQLITE3_OPEN_READWRITE'))
		{







>
|
>
>







48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
	 */
	protected $flags = null;

	const DATE_FORMAT = 'Y-m-d H:i:s';

	public function close(): void
	{
		if (null !== $this->db) {
			$this->db->close();
		}

		$this->db = null;
	}

	public function __construct(string $driver, array $params)
	{
		if (!defined('\SQLITE3_OPEN_READWRITE'))
		{
114
115
116
117
118
119
120












121
122
123
124
125
126
127
		else
		{
			$this->sqlite_functions[$name] = $callback;
			return true;
		}
	}














	public function escapeString(string $str): string
	{
		// escapeString is not binary safe: https://bugs.php.net/bug.php?id=62361
		$str = str_replace("\0", "\\0", $str);

		return \SQLite3::escapeString($str);







>
>
>
>
>
>
>
>
>
>
>
>







117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
		else
		{
			$this->sqlite_functions[$name] = $callback;
			return true;
		}
	}

	public function createCollation(string $name, callable $callback): bool
	{
		if ($this->db)
		{
			return $this->db->createCollation($name, $callback);
		}
		else
		{
			$this->sqlite_collations[$name] = $callback;
			return true;
		}
	}

	public function escapeString(string $str): string
	{
		// escapeString is not binary safe: https://bugs.php.net/bug.php?id=62361
		$str = str_replace("\0", "\\0", $str);

		return \SQLite3::escapeString($str);