Pluf Framework

Pluf Framework Commit Details


Date:2009-01-12 14:25:29 (15 years 11 months ago)
Author:Loic d'Anterroches
Branch:develop, master
Commit:7a31ad2a7ceef876df8eb73e84c97925ef7a9e50
Parents: d5c9f879052d230261f6a92c88d4af8141b1b027
Message:Fixed the handling of the output errors in the PostgreSQL connection.

Changes:

File differences

src/Pluf/DB/PostgreSQL.php
2626
2727
2828
29
30
31
2932
33
34
35
36
3037
38
39
40
41
3142
32
43
44
45
46
47
3348
49
50
51
52
3453
54
55
56
57
58
59
60
3561
3662
63
64
65
66
67
3768
3869
3970
4071
41
42
72
73
74
75
4376
4477
4578
......
5083
5184
5285
53
5486
5587
56
88
89
5790
5891
5992
......
104137
105138
106139
107
108
109
140
141
110142
111143
112144
113
145
114146
115147
116148
......
121153
122154
123155
124
125
126
127
128
156
157
129158
130159
160
131161
132162
133163
*/
class Pluf_DB_PostgreSQL
{
/**
* The connection resource.
*/
public $con_id;
/**
* The prefix for the table names.
*/
public $pfx = '';
/**
* Debug mode.
*/
private $debug = false;
/** The last query, set with debug(). Used when an error is returned. */
/**
* The last query, set with debug(). Used when an error is
* returned.
*/
public $lastquery = '';
/**
* Name of the engine.
*/
public $engine = 'PostgreSQL';
/**
* Used by the model to convert the values from and to the
* database.
*
* @see Pluf_DB_defaultTypecast
*/
public $type_cast = array();
/**
* Current query cursor.
*/
private $cur = null;
function __construct($user, $pwd, $server, $dbname, $pfx='', $debug=false)
{
Pluf::loadFunction('Pluf_DB_defaultTypecast');
$this->type_cast = Pluf_DB_defaultTypecast();
$this->type_cast['Pluf_DB_Field_Boolean'] = array('Pluf_DB_PostgreSQL_BooleanFromDb', 'Pluf_DB_BooleanToDb');
$this->type_cast['Pluf_DB_Field_Compressed'] = array('Pluf_DB_PostgreSQL_CompressedFromDb', 'Pluf_DB_PostgreSQL_CompressedToDb');
$this->type_cast['Pluf_DB_Field_Boolean'] =
array('Pluf_DB_PostgreSQL_BooleanFromDb', 'Pluf_DB_BooleanToDb');
$this->type_cast['Pluf_DB_Field_Compressed'] =
array('Pluf_DB_PostgreSQL_CompressedFromDb', 'Pluf_DB_PostgreSQL_CompressedToDb');
$this->debug('* POSTGRESQL CONNECT');
$cstring = '';
if ($pwd) {
$cstring .= ' password='.$pwd;
}
$this->con_id = pg_connect($cstring);
$this->debug = $debug;
$this->pfx = $pfx;
$this->cur = null; //Current query cursor.
$this->cur = null;
$this->con_id = @pg_connect($cstring);
if (!$this->con_id) {
throw new Exception($this->getError());
}
function select($query)
{
$this->debug($query);
try {
$this->cur = @pg_query($this->con_id, $query);
} catch (Exception $e) {
$this->cur = @pg_query($this->con_id, $query);
if (!$this->cur) {
throw new Exception($this->getError());
}
$res = array();
while ($row = @pg_fetch_assoc($this->cur)) {
while ($row = pg_fetch_assoc($this->cur)) {
$res[] = $row;
}
@pg_free_result($this->cur);
function execute($query)
{
$this->debug($query);
try {
$this->cur = @pg_query($this->con_id, $query);
$this->cur = null;
return true;
} catch (Exception $e) {
$this->cur = @pg_query($this->con_id, $query);
if (!$this->cur) {
throw new Exception($this->getError());
}
return true;
}
function getLastID()

Archive Download the corresponding diff file

Branches

Tags

Number of commits:
Page rendered in 0.05690s using 13 queries.