コード例 #1
0
ファイル: SqlDb.php プロジェクト: rajeshpillai/df-sqldb
 /**
  * Create a new SqlDbSvc
  *
  * @param array $settings
  *
  * @throws \InvalidArgumentException
  * @throws \Exception
  */
 public function __construct($settings = [])
 {
     parent::__construct($settings);
     $config = ArrayUtils::clean(ArrayUtils::get($settings, 'config'));
     Session::replaceLookups($config, true);
     $driver = isset($config['driver']) ? $config['driver'] : null;
     $this->dbConn = ConnectionFactory::createConnection($driver, $config);
     $this->dbConn->setCache($this);
     $this->dbConn->setExtraStore($this);
     $defaultSchemaOnly = ArrayUtils::getBool($config, 'default_schema_only');
     $this->dbConn->setDefaultSchemaOnly($defaultSchemaOnly);
     switch ($this->dbConn->getDBName()) {
         case SqlDbDriverTypes::MYSQL:
         case SqlDbDriverTypes::MYSQLI:
             $this->dbConn->setAttribute(\PDO::ATTR_EMULATE_PREPARES, true);
             break;
         case SqlDbDriverTypes::DBLIB:
             $this->dbConn->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
             break;
     }
     $attributes = ArrayUtils::clean(ArrayUtils::get($settings, 'attributes'));
     if (!empty($attributes)) {
         $this->dbConn->setAttributes($attributes);
     }
 }
コード例 #2
0
ファイル: BaseModel.php プロジェクト: pkdevboxy/df-core
 /**
  * Gets the TableSchema for this model.
  *
  * @return TableSchema
  */
 public function getTableSchema()
 {
     if (empty($this->adaptedConnection)) {
         $connection = $this->getConnection();
         $this->adaptedConnection = ConnectionAdapter::getLegacyConnection($connection);
         $this->cachePrefix = 'model_' . $this->getTable() . ':';
         $this->adaptedConnection->setCache($this);
     }
     return $this->adaptedConnection->getSchema()->getTable($this->table);
 }