forked from PocketRent/hhvm-pgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdo_pgsql.cpp
60 lines (50 loc) · 1.56 KB
/
pdo_pgsql.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "pdo_pgsql.h"
#include "pdo_pgsql_connection.h"
#include "pdo_pgsql_resource.h"
namespace HPHP {
// Initialize the extension
static PDOPgSql s_pgsql_driver;
PDOPgSql::PDOPgSql() : PDODriver("pgsql") {
PQinitSSL(0);
}
SmartPtr<PDOResource> PDOPgSql::createResourceImpl() {
return makeSmartPtr<PDOPgSqlResource>(std::make_shared<PDOPgSqlConnection>());
}
SmartPtr<PDOResource> PDOPgSql::createResourceImpl(const sp_PDOConnection& conn) {
return makeSmartPtr<PDOPgSqlResource>(
std::dynamic_pointer_cast<PDOPgSqlConnection>(conn)
);
}
long pdo_attr_lval(const Array& options, int opt, long defaultValue){
if(options.exists(opt)){
return options[opt].toInt64();
}
return defaultValue;
}
String pdo_attr_strval(const Array& options, int opt, const char *def){
if(options.exists(opt)){
return options[opt].toString();
}
if(def){
return def;
}
return String();
}
const StaticString s_PDO("PDO");
static class PDOPGSQLExtension : public Extension {
public:
PDOPGSQLExtension() : Extension("pdo_pgsql") {}
virtual void moduleLoad(const IniSetting::Map& ini, Hdf hdf) {
Native::registerClassConstant<KindOfInt64>(
s_PDO.get(),
s_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT.get(),
PDO_PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT
);
Native::registerClassConstant<KindOfInt64>(
s_PDO.get(),
s_PGSQL_ATTR_DISABLE_PREPARES.get(),
PDO_PGSQL_ATTR_DISABLE_PREPARES
);
}
} s_pdopgsql_extension;
}