{"id":14966894,"url":"https://github.com/neconix/yii2-oci8","last_synced_at":"2025-07-02T16:35:50.782Z","repository":{"id":53123981,"uuid":"67036608","full_name":"Neconix/Yii2-Oci8","owner":"Neconix","description":"Yii2 extension which uses well written yajra/pdo-via-oci8 package for standard PHP Oracle functions (OCI8)","archived":false,"fork":false,"pushed_at":"2021-04-05T20:01:19.000Z","size":16,"stargazers_count":10,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-31T09:51:10.651Z","etag":null,"topics":["oci","pdo","yii2-extension","yii2-oci8"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Neconix.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-31T12:46:21.000Z","updated_at":"2024-06-05T06:50:01.000Z","dependencies_parsed_at":"2022-08-23T13:51:04.198Z","dependency_job_id":null,"html_url":"https://github.com/Neconix/Yii2-Oci8","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neconix%2FYii2-Oci8","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neconix%2FYii2-Oci8/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neconix%2FYii2-Oci8/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Neconix%2FYii2-Oci8/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Neconix","download_url":"https://codeload.github.com/Neconix/Yii2-Oci8/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238184004,"owners_count":19430241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["oci","pdo","yii2-extension","yii2-oci8"],"created_at":"2024-09-24T13:37:06.716Z","updated_at":"2025-02-10T20:32:40.839Z","avatar_url":"https://github.com/Neconix.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Yii2-Oci8\nYii2 OCI8 extension which uses well written [yajra/pdo-via-oci8](https://github.com/yajra/pdo-via-oci8) \nwith optional full table schema caching. Supported PHP7.\n\n**Supported**\n- Yii 2.x;\n- yajra/pdo-via-oci8 1.x;\n- \\\u003e= PHP 5.4;\n- \\\u003e= PHP 7.0.\n\n**Installation**\n\nAdd to your `composer.json` file:\n\n```\n   \"require\": {\n     \"neconix/yii2-oci8\": \"1.*\"\n   }\n```\n\nAnd then run `composer update`.\n\n**Yii2 configuration example for an Oracle database**\n\nYii2 configuration:\n\n```php\n$config = [\n    ...\n    'components' =\u003e [\n        ...\n        'db' =\u003e require(__DIR__ . '/db.php'),\n        ...\n    ]\n];\n```\n\nDatabase configuration in `db.php`:\n\n```php\nreturn [\n    'class' =\u003e 'neconix\\yii2oci8\\Oci8Connection',\n    'dsn' =\u003e 'oci:dbname=//192.168.0.1:1521/db.local;charset=AL32UTF8;',\n    'username' =\u003e 'user',\n    'password' =\u003e 'pass',\n    'attributes' =\u003e [ PDO::ATTR_PERSISTENT =\u003e true ],\n    'enableSchemaCache' =\u003e true, //Oracle dictionaries is too slow :(, enable caching\n    'schemaCacheDuration' =\u003e 60 * 60, //1 hour\n    'on afterOpen' =\u003e function($event) {\n\n    /* A session configuration example */\n        $q = \u003c\u003c\u003cSQL\nbegin\n  execute immediate 'alter session set NLS_SORT=BINARY_CI';\n  execute immediate 'alter session set NLS_TERRITORY=AMERICA';\nend;\nSQL;\n        $event-\u003esender-\u003ecreateCommand($q)-\u003eexecute();\n    }\n];\n```\n\n**Example**\n\nFeel free to use Yii2 `ActiveRecord` methods:\n\n```php\n$cars = Car::find()-\u003ewhere(['YEAR' =\u003e '1939'])-\u003eindexBy('ID')-\u003eall();\n```\n\nGetting a raw database handler and working with it:\n\n```php\n$dbh = Yii::$app-\u003edb-\u003egetDbh();\n$stmt = oci_parse($dbh, \"select * from DEPARTMENTS where NAME = :name\");\n$name = 'NYPD';\noci_bind_by_name($stmt, ':name', $name);\noci_execute($stmt);\n...\n//fetching result\n```\n\n**Caching features**\n\nTo enable caching for all tables in a schema add lines below in a database connection configuration `db.php`:\n\n```php\n    ...\n    //Disabling Yii2 schema cache\n    'enableSchemaCache' =\u003e false\n    \n    //Defining a cache schema component\n    'cachedSchema' =\u003e [\n        'class' =\u003e 'neconix\\yii2oci8\\CachedSchema',\n        // Optional, default is the current connection schema.\n        'cachingSchemas' =\u003e ['HR', 'SCOTT'],\n        // Optional. This callback must return `true` for a table name if it need to be cached.\n        'tableNameFilter' =\u003e function ($tableName, $schemaName) {\n            //Cache everything but the EMP table from HR and SCOTT schemas\n            return $tableName != 'EMP';\n        }\n    ],\n    ...\n```\n\nTable schemas saves to the default Yii2 cache component.\nTo build schema cache after a connection opens:\n\n```php\n    'on afterOpen' =\u003e function($event) \n    {\n        $event-\u003esender-\u003ecreateCommand($q)-\u003eexecute();\n\n        /* @var $schema \\neconix\\yii2oci8\\CachedSchema */\n        $schema = $event-\u003esender-\u003egetSchema();\n\n        if (!$schema-\u003eisCached)\n            //Rebuild schema cache\n            $schema-\u003ebuildSchemaCache();\n    },\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneconix%2Fyii2-oci8","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneconix%2Fyii2-oci8","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneconix%2Fyii2-oci8/lists"}