Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F12373695
PostgreSQLPDOEngine.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
PostgreSQLPDOEngine.php
View Options
<?php
namespace
Keruald\Database\Engines
;
use
Keruald\Database\Exceptions\NotImplementedException
;
use
PDO
;
use
PDOException
;
use
RuntimeException
;
class
PostgreSQLPDOEngine
extends
PDOEngine
{
use
WithPDOPostgreSQL
;
const
string
PDO_CLASS
=
PDO
::
class
;
public
function
__construct
(
string
$host
=
'localhost'
,
string
$username
=
'root'
,
string
$password
=
''
,
string
$database
=
''
)
{
// Checks extension requirement
if
(!
class_exists
(
self
::
PDO_CLASS
))
{
throw
new
RuntimeException
(
"This engine requires PDO extension."
);
}
// Connects to PostgreSQL server
$dsn
=
"pgsql:host=$host"
;
if
(
$database
!==
""
)
{
$dsn
.=
";dbname=$database"
;
}
try
{
$this
->
db
=
new
PDO
(
$dsn
,
$username
,
$password
);
}
catch
(
PDOException
$ex
)
{
$this
->
lastException
=
$ex
;
$this
->
onCantConnectToHost
();
return
;
}
$this
->
db
->
setAttribute
(
PDO
::
ATTR_ERRMODE
,
PDO
::
ERRMODE_EXCEPTION
);
}
///
/// Not implemented features
///
/**
* @throws NotImplementedException
*/
public
function
escape
(
string
$expression
)
:
string
{
throw
new
NotImplementedException
(<<<
END
This
PDO
engine
does
not
support
escape
for
literals
.
Placeholders
are
recommended
instead
for
PDO
operations
.
END
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 1, 18:16 (23 h, 29 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3116221
Default Alt Text
PostgreSQLPDOEngine.php (1 KB)
Attached To
Mode
rKDB Keruald Database
Attached
Detach File
Event Timeline
Log In to Comment