Yii2 - Oracle connection - set date format





        'db' => [
            'class' => 'apaoww\oci8\Oci8DbConnection',
            'dsn' => 'oci8:dbname=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=XXX)));charset=UTF8;', // Oracle
            'username' => 'xx',
            'password' => 'xxx#',
            'attributes' => [
                PDO::ATTR_STRINGIFY_FETCHES => true,
            ],
            'enableSchemaCache' => true,
            // Duration of schema cache.
            'schemaCacheDuration' => 3600,
            // Name of the cache component used to store schema information
            'schemaCache' => 'cache',
            'on afterOpen' => function ($event) {
                $event->sender->createCommand("ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS'")->execute();
            }
        ],

No comments:

Post a Comment