/** * 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); } }
public function getApiDocInfo() { $base = parent::getApiDocInfo(); $wrapper = ResourcesWrapper::getWrapper(); $models = ['TableSchemas' => ['id' => 'TableSchemas', 'properties' => [$wrapper => ['type' => 'Array', 'description' => 'An array of table definitions.', 'items' => ['$ref' => 'TableSchema']]]], 'TableSchema' => ['id' => 'TableSchema', 'properties' => ['name' => ['type' => 'string', 'description' => 'Identifier/Name for the table.'], 'label' => ['type' => 'string', 'description' => 'Displayable singular name for the table.'], 'plural' => ['type' => 'string', 'description' => 'Displayable plural name for the table.'], 'primary_key' => ['type' => 'string', 'description' => 'Field(s), if any, that represent the primary key of each record.'], 'name_field' => ['type' => 'string', 'description' => 'Field(s), if any, that represent the name of each record.'], 'field' => ['type' => 'Array', 'description' => 'An array of available fields in each record.', 'items' => ['$ref' => 'FieldSchema']]]], 'FieldSchema' => ['id' => 'FieldSchema', 'properties' => ['name' => ['type' => 'string', 'description' => 'The API name of the field.'], 'label' => ['type' => 'string', 'description' => 'The displayable label for the field.'], 'type' => ['type' => 'string', 'description' => 'The DSP abstract data type for this field.'], 'db_type' => ['type' => 'string', 'description' => 'The native database type used for this field.'], 'is_primary_key' => ['type' => 'boolean', 'description' => 'Is this field used as/part of the primary key.'], 'validation' => ['type' => 'Array', 'description' => 'validations to be performed on this field.', 'items' => ['type' => 'string']], 'picklist' => ['type' => 'Array', 'description' => 'Selectable string values for client menus and picklist validation.', 'items' => ['type' => 'string']]]]]; $base['models'] = array_merge($base['models'], $models); return $base; }