diff options
| author | 2020-12-28 10:44:08 -0500 | |
|---|---|---|
| committer | 2020-12-28 16:44:08 +0100 | |
| commit | e1ee58816ba76734e4115fc12898b13de665b220 (patch) | |
| tree | 04a64bb11de9d4c69cff309329ede119f9b7a760 /lib/Minz/PdoPgsql.php | |
| parent | ac0d90c1008bce32c56e49cb642d40391e45e0a5 (diff) | |
Add a file for each PDO class (#3297)
Before, we had 5 classes in the ModelPdo file. It was bad for 2 reasons.
The first reason is that it is considered bad practice to have multiple
class in one file. This is especially true when using autoloading. On top
of that it is less readable considering the size of the file. The second
reason is that so far we were lucky. Everytime we needed to access the
database, it was through the ModelPdo class which loads all the other
classes. If we want to access directly the connection, it wont be loaded.
On top of that, the system is configured to work on a single database,
but as we have every connection definition in a single file, all classes
were loaded at the same time. Thus using memory and processing time for
nothing.
Now, we have a file for each class. To work with autoloading, classes
were slightly renamed to match autoloading rules.
Diffstat (limited to 'lib/Minz/PdoPgsql.php')
| -rw-r--r-- | lib/Minz/PdoPgsql.php | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/Minz/PdoPgsql.php b/lib/Minz/PdoPgsql.php new file mode 100644 index 000000000..7d1a1912b --- /dev/null +++ b/lib/Minz/PdoPgsql.php @@ -0,0 +1,22 @@ +<?php + +/** + * MINZ - Copyright 2011 Marien Fressinaud + * Sous licence AGPL3 <http://www.gnu.org/licenses/> + */ + +class Minz_PdoPgsql extends Minz_Pdo { + public function __construct($dsn, $username = null, $passwd = null, $options = null) { + parent::__construct($dsn, $username, $passwd, $options); + $this->exec("SET NAMES 'UTF8';"); + } + + public function dbType() { + return 'pgsql'; + } + + protected function preSql($statement) { + $statement = parent::preSql($statement); + return str_replace(array('`', ' LIKE '), array('"', ' ILIKE '), $statement); + } +} |
