示例#1
0
文件: PDO.php 项目: crate/crate-pdo
 /**
  * {@inheritDoc}
  */
 public function setAttribute($attribute, $value)
 {
     switch ($attribute) {
         case self::ATTR_DEFAULT_FETCH_MODE:
             $this->attributes['defaultFetchMode'] = $value;
             break;
         case self::ATTR_ERRMODE:
             $this->attributes['errorMode'] = $value;
             break;
         case self::ATTR_TIMEOUT:
             $this->attributes['timeout'] = (int) $value;
             if (is_object($this->client)) {
                 $this->client->setTimeout((int) $value);
             }
             break;
         case self::CRATE_ATTR_HTTP_BASIC_AUTH:
             $this->attributes['auth'] = $value;
             if (is_object($this->client) && is_array($value)) {
                 list($user, $password) = $value;
                 $this->client->setHttpBasicAuth($user, $password);
             }
             break;
         case self::CRATE_ATTR_DEFAULT_SCHEMA:
             $this->attributes['defaultSchema'] = $value;
             if (is_object($this->client)) {
                 $this->client->setDefaultSchema($value);
             }
             break;
         default:
             throw new Exception\PDOException('Unsupported driver attribute');
     }
 }