Closed webbird closed 10 years ago
Simple way to use prepared statement with little effort (example taken from CAT_Helper_Addons):
$addon = $self->db()->query(
'SELECT * FROM `:prefix:addons` WHERE addon_id=:id',
array('id'=>$id)
);
Please note that there is no need to use something like
'SELECT * FROM '.CAT_TABLE_PREFIX.'tablename ...'
or
sprintf( 'SELECT * FROM %stablename ...',CAT_TABLE_PREFIX)
anymore. The :prefix:
placeholder will be replaced by the class.database.php
.
I've renamed some methods. Old methods are still available with $database global.
is_error -> isError get_error -> getError set_error -> setError (private)
New:
qb() -> returns Query Builder object conn() -> returns connection object resetError() -> cleans up error stack prefix() -> returns CAT_TABLE_PREFIX prepare() -> wrapper for PDO prepare(), replaces :prefix: in query string
This issue collects commits concerning the switch to the Doctrine DBAL. We should prefer to use prepared statements whenever possible.