Closed spohess closed 8 years ago
Could you show what changes you needed? I presume that everything uses proper types (Carbon/DateTime, sql parameters, ...) and no change should be needed to adapt to any database presentation format. (Or are you persisting your datetimes as strings/varchar?)
Hi @sisve!
In my code I had to add a method to execute this "ALTER SESSION SET $key = '$value'".
This is my code:
public function __construct() {
$this->setOracleEnv(getEnvOracle());
}
private function setOracleEnv(Array $variable) {
if (env('DB_CONNECTION', 'oracle') === 'oracle') {
foreach ($variable as $key => $value) {
$formato = EntityManager::getConnection()->prepare("ALTER SESSION SET $chave = '$valor'");
$formato->execute();
}
}
}
if (! function_exists( 'getEnvOracle' ))
{
function getEnvOracle()
{
$env = [
'NLS_TIME_FORMAT' => "HH24:MI:SS",
'NLS_DATE_FORMAT' => "YYYY-MM-DD HH24:MI:SS",
'NLS_TIMESTAMP_FORMAT' => "YYYY-MM-DD HH24:MI:SS",
'NLS_TIMESTAMP_TZ_FORMAT' => "YYYY-MM-DD HH24:MI:SS TZH:TZM",
'NLS_NUMERIC_CHARACTERS' => ".,",
];
return $env;
}
}
I tried others solutions, but not work and I don't found more examples for this situation. Something in Carbon resolve this?
No, I do not persist datetime as string/varchar only type="datetime"
I had trouble using Timestamps extensions because my database is set with the default format 'd-M-y h:i:s A' and I couldn't change this. So, I had that create a method in my main repository to alter the session before execute anything.
This solution works very well for us. Can I put this solution on source? What file I can put this code?
Thanks a lot!