Français
Description et utilisation
Avec ce patch, on peut utiliser un nouveau paramètre "table_prefix" pour les profils de connexion aux bases de données.
Ce paramètre n'est pas requis, le patch fonctionnera avec ou sans.
Définissez votre préfixe de la façon suivante :
[myprofile]
....
table_prefix = "myprefix_"
Quand on utilise jDao, le préfixe est utilisé automatiquement.
Quand on utilise jDb, on doit préfixer explicitement les tables :
$cnx = jDb::getConnection();
$result = $cnx->query('select * from '.$cnx->prefixTable('news').' where category = 10);
Notes techniques
Dans lib/jelix/dao/jDaoGenerator.class.php, j'ai du surcharger le constructeur de jDaoFactoryBase, car la propriété _fromClause est à présent liée dynamiquement au paramètre "table_prefix", et ne peut dont plus être déclarée directement.
English
Description and usage
With this patch, you can set a new parameter called "table_prefix" in your databases' connection profiles.
This new parameter is not required, the patch will work whether it is set or not.
Set your profile prefix like that :
[myprofile]
....
table_prefix = "myprefix_"
When using jDao, you have nothing to do, it all works automatically.
When using jDb, you have to explicitly prefix tables with the new prefixTable method :
$cnx = jDb::getConnection();
$result = $cnx->query('select * from '.$cnx->prefixTable('news').' where category = 10);
Tech notes
In lib/jelix/dao/jDaoGenerator.class.php, I had to overload the constructor of jDaoFactoryBase, because the property _fromClause is now dynamically linked to the connection profile's "table_prefix" parameter, and thus it cannot be set directly anymore.