Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once 'class.sql_pool.php';
- class sql_pool_pdo extends PropelPDO {
- /**
- * Construct a new sql_pool_pdo connection.
- *
- * This method is overridden in order to specify a custom PDOStatement class.
- *
- * @param string $dsn Connection DSN
- * @param string $username (optional
- * @param string $password
- * @param array $driver_options
- * @throws PDOException - if there is an error during connection initialization
- */
- public function __construct($dsn, $username = null, $password = null, $driver_options = array())
- {
- error_log("dsn1:$dsn; username=$username; password=$password; opts=".print_r($driver_options,1));
- list($prefix, $props) = explode(':', $dsn, 2);
- if ($prefix == 'sql_pool') {
- // for sql_pool we rewrite $dsn whatever it gives us
- $schema = null;
- foreach (explode(';', $props) as $prop) {
- list($key, $value) = explode('=', $prop, 2);
- if ($key == 'schema') {
- $schema = $value;
- break;
- }
- }
- if (is_null($schema)) {
- throw new PropelException("No schema found from dsn: " . $dsn. ": Check your configuration file");
- }
- $props = sql_pool::get_schema($schema);
- $dsn = 'mysql:dbname='.$props['dbname'];
- if ($props['host']) {
- $dsn .= ';host='.$props['host'];
- }
- if ($props['port']) {
- $dsn .= ';port='.$props['port'];
- }
- if ($props['socket']) {
- $dsn .= ';unix_socket='.$props['socket'];
- }
- $username = $props['user'];
- $password = $props['pass'];
- }
- error_log("dsn2:$dsn; username=$username; password=$password; opts=".print_r($driver_options,1));
- parent::__construct($dsn, $username, $password, $driver_options);
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement