Overview
Comment:Prepend AND to WHERE clause in sql template sections, if missing, thanks @zou
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e3170a7744bac9d682978f2600ab3a98c6484a0d23bfbc0ac2bddbeca6110d1c
User & Date: bohwaz on 2021-06-18 09:37:22
Other Links: manifest | tags
Context
2021-06-18
09:42
Fix atom_date modifier, thanks @zou check-in: 4a609e78c7 user: bohwaz tags: trunk, 1.1.8
09:37
Prepend AND to WHERE clause in sql template sections, if missing, thanks @zou check-in: e3170a7744 user: bohwaz tags: trunk
2021-06-10
23:10
Fix bug [3747fb82b8b42ec6] trying to remove an index that does not exist check-in: 9714d59a06 user: bohwaz tags: trunk
Changes

Modified src/include/lib/Garradin/UserTemplate/Sections.php from [9a0667f343] to [b168f12ea3].

291
292
293
294
295
296
297




298
299
300
301
302
303
304
		}

		// Allow for count=true, count=1 and also count="DISTINCT user_id" count="id"
		if (!empty($params['count'])) {
			$params['select'] = sprintf('COUNT(%s) AS count', $params['count'] == 1 ? '*' : $params['count']);
			$params['order'] = '1';
		}





		$sql = sprintf('SELECT %s FROM %s WHERE 1 %s %s ORDER BY %s LIMIT %d,%d;',
			$params['select'],
			$params['tables'],
			$params['where'] ?? '',
			isset($params['group']) ? 'GROUP BY ' . $params['group'] : '',
			$params['order'],







>
>
>
>







291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
		}

		// Allow for count=true, count=1 and also count="DISTINCT user_id" count="id"
		if (!empty($params['count'])) {
			$params['select'] = sprintf('COUNT(%s) AS count', $params['count'] == 1 ? '*' : $params['count']);
			$params['order'] = '1';
		}

		if (!empty($params['where']) && !preg_match('/^\s*AND\s+/i', $params['where'])) {
			$params['where'] = ' AND ' . $params['where'];
		}

		$sql = sprintf('SELECT %s FROM %s WHERE 1 %s %s ORDER BY %s LIMIT %d,%d;',
			$params['select'],
			$params['tables'],
			$params['where'] ?? '',
			isset($params['group']) ? 'GROUP BY ' . $params['group'] : '',
			$params['order'],