mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-05-15 12:37:34 +08:00
announce support pg
This commit is contained in:
@@ -151,6 +151,11 @@ class NexusDB
|
||||
return $this->driver->freeResult($result);
|
||||
}
|
||||
|
||||
public function prepare(string $sql)
|
||||
{
|
||||
return $this->driver->prepare($sql);
|
||||
}
|
||||
|
||||
public function isConnected()
|
||||
{
|
||||
return $this->isConnected;
|
||||
@@ -506,4 +511,15 @@ class NexusDB
|
||||
return compact('version', 'match', 'minVersion', 'dbType');
|
||||
}
|
||||
|
||||
public static function unixTimestampField(string $field): string
|
||||
{
|
||||
if (self::isMysql()) {
|
||||
return sprintf("UNIX_TIMESTAMP(%s)", $field);
|
||||
} elseif (self::isPgsql()) {
|
||||
return sprintf("EXTRACT(EPOCH FROM %s)", $field);
|
||||
} else {
|
||||
throw new \RuntimeException('Not supported database.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user