fluiddb 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/FluidDb/Pgsql.rb +71 -71
- metadata +1 -1
data/lib/FluidDb/Pgsql.rb
CHANGED
@@ -20,86 +20,86 @@ module FluidDb
|
|
20
20
|
|
21
21
|
return hash
|
22
22
|
end
|
23
|
+
|
24
|
+
def queryForArray( sql, params )
|
25
|
+
sql = self.format_to_sql( sql, params )
|
26
|
+
results = @connection.exec(sql)
|
23
27
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# if ( $result === false ) then
|
29
|
-
# $message = pg_last_error( $this->connection );
|
30
|
-
# throw new Fluid_ConnectionException( $message );
|
31
|
-
#end
|
32
|
-
|
33
|
-
case results.num_tuples
|
34
|
-
when -1
|
35
|
-
raise FluidDb::ConnectionError.new
|
36
|
-
when 0
|
37
|
-
raise FluidDb::NoDataFoundError.new
|
38
|
-
when 1
|
39
|
-
return self.convertTupleToHash(results.fields, results, 0)
|
40
|
-
else
|
41
|
-
raise FluidDb::TooManyRowsError.new
|
42
|
-
end
|
43
|
-
end
|
28
|
+
# if ( $result === false ) then
|
29
|
+
# $message = pg_last_error( $this->connection );
|
30
|
+
# throw new Fluid_ConnectionException( $message );
|
31
|
+
#end
|
44
32
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
case results.num_tuples
|
55
|
-
when -1
|
56
|
-
raise FluidDb::ConnectionError.new
|
57
|
-
when 0
|
58
|
-
raise FluidDb::NoDataFoundError.new
|
59
|
-
when 1
|
60
|
-
return results.getvalue(0,0)
|
61
|
-
else
|
62
|
-
raise FluidDb::TooManyRowsError.new
|
63
|
-
end
|
64
|
-
|
33
|
+
case results.num_tuples
|
34
|
+
when -1
|
35
|
+
raise FluidDb::ConnectionError.new
|
36
|
+
when 0
|
37
|
+
raise FluidDb::NoDataFoundError.new
|
38
|
+
when 1
|
39
|
+
return self.convertTupleToHash(results.fields, results, 0)
|
40
|
+
else
|
41
|
+
raise FluidDb::TooManyRowsError.new
|
65
42
|
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def queryForValue( sql, params )
|
46
|
+
sql = self.format_to_sql( sql, params )
|
47
|
+
results = @connection.exec(sql)
|
48
|
+
|
49
|
+
# if ( $result === false ) then
|
50
|
+
# $message = pg_last_error( $this->connection );
|
51
|
+
# throw new Fluid_ConnectionException( $message );
|
52
|
+
#end
|
66
53
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
case results.num_tuples
|
78
|
-
when -1
|
79
|
-
raise FluidDb::ConnectionError.new
|
80
|
-
else
|
81
|
-
list = Array.new
|
82
|
-
fields = results.fields
|
83
|
-
0.upto( results.num_tuples -1 ) do |nbr|
|
84
|
-
list.push self.convertTupleToHash(fields, results, nbr)
|
85
|
-
end
|
86
|
-
|
87
|
-
return list
|
88
|
-
end
|
54
|
+
case results.num_tuples
|
55
|
+
when -1
|
56
|
+
raise FluidDb::ConnectionError.new
|
57
|
+
when 0
|
58
|
+
raise FluidDb::NoDataFoundError.new
|
59
|
+
when 1
|
60
|
+
return results.getvalue(0,0)
|
61
|
+
else
|
62
|
+
raise FluidDb::TooManyRowsError.new
|
89
63
|
end
|
90
64
|
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
def queryForResultset( sql, params )
|
69
|
+
sql = self.format_to_sql( sql, params )
|
70
|
+
results = @connection.exec(sql)
|
91
71
|
|
92
|
-
#
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
end
|
72
|
+
# if ( $result === false ) then
|
73
|
+
# $message = pg_last_error( $this->connection );
|
74
|
+
# throw new Fluid_ConnectionException( $message );
|
75
|
+
#end
|
97
76
|
|
98
|
-
|
99
|
-
|
100
|
-
|
77
|
+
case results.num_tuples
|
78
|
+
when -1
|
79
|
+
raise FluidDb::ConnectionError.new
|
80
|
+
else
|
81
|
+
list = Array.new
|
82
|
+
fields = results.fields
|
83
|
+
0.upto( results.ntuples() -1 ) do |nbr|
|
84
|
+
list.push self.convertTupleToHash(fields, results, nbr)
|
85
|
+
end
|
86
|
+
|
87
|
+
return list
|
101
88
|
end
|
102
|
-
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
# def execute( sql, params, expected_affected_rows )
|
93
|
+
def execute( sql, params )
|
94
|
+
sql = self.format_to_sql( sql, params )
|
95
|
+
@connection.query( sql );
|
96
|
+
end
|
97
|
+
|
98
|
+
def insert( sql, params )
|
99
|
+
self.execute( sql, params )
|
100
|
+
return @connection.last_id
|
103
101
|
end
|
104
102
|
|
105
103
|
end
|
104
|
+
|
105
|
+
end
|