Exemple #1
0
 /**
  * This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor.
  * Call it when you need to restore a database connection.
  *
  * @param array|null $descriptor
  * @return boolean
  * @throws Exception
  */
 public function connect($descriptor = null)
 {
     if (is_null($descriptor) === true) {
         $descriptor = $this->_descriptor;
     } elseif (is_array($descriptor) === false) {
         throw new Exception('Invalid parameter type.');
     }
     if (isset($descriptor['dbname']) === false) {
         throw new Exception('dbname must be specified');
     }
     $descriptor['dns'] = $descriptor['dbname'];
     parent::connect($descriptor);
 }
Exemple #2
0
 /**
  * This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor.
  * Call it when you need to restore a database connection.
  *
  * @param array $descriptor
  * @return bool
  */
 public function connect(array $descriptor = null)
 {
     if (empty($descriptor)) {
         $descriptor = $this->_descriptor;
     }
     $status = parent::connect($descriptor);
     if (isset($descriptor['startup']) && $descriptor['startup']) {
         $startup = $descriptor['startup'];
         if (!is_array($startup)) {
             $startup = [$startup];
         }
         foreach ($startup as $value) {
             $this->execute($value);
         }
     }
     return $status;
 }
Exemple #3
0
 /**
  * This method is automatically called in \Phalcon\Db\Adapter\Pdo constructor.
  * Call it when you need to restore a database connection.
  *
  * Support set search_path after connectted if schema is specified in config.
  *
  * @param array|null $descriptor
  * @return boolean
  * @throws Exception
  */
 public function connect($descriptor = null)
 {
     if (is_null($descriptor) === true) {
         $descriptor = $this->_descriptor;
     } elseif (is_array($descriptor) === false) {
         throw new Exception('Invalid parameter type.');
     }
     if (isset($descriptor['schema']) === true) {
         $schema = $descriptor['schema'];
         unset($descriptor['schema']);
     } else {
         $schema = null;
     }
     parent::connect($descriptor);
     //Execute the search path in the after connect
     if (is_string($schema) === true) {
         $this->execute("SET search_path TO '" . $schema . "'");
     }
 }