Hello all,

Currently, I have basic postgres working, except for one thing:
When data is inserted, datatypes are converted from PHP to their
matching database types.  Ie, a boolean value is converted to 't'
or 'f' in pgsql, and to '1' or '0' in mysqli.  However, when the
same data is fetched back again by a query, this is NOT done.

That means if you do a select after you do an insert, it will
not result in the same sort of data that you just inserted, and
worse: the value you get back is always a string, with the contents
being database-dependent.  In postgres you get 't' or 'f' and in
mysql you get '1' or '0'.

MDB2 has the necessary code to automatically convert return types,
and it appears enabling type introspection to make it automatically
work is a simple matter of changing the second '$types' parameter
of the query() method from NULL to TRUE:


diff -r 491a9039ec03 common/libraries/php/database/database.class.php
--- a/common/libraries/php/database/database.class.php  Wed Jan 19 12:08:42 
2011 +0100
+++ b/common/libraries/php/database/database.class.php  Wed Jan 19 15:02:44 
2011 +0100
@@ -890,7 +890,7 @@
         return $this->connection->escape($text, $escape_wildcards);
     }
 
-    function query($query, $types = null, $result_class = true, 
$result_wrap_class = false)
+    function query($query, $types = true, $result_class = true, 
$result_wrap_class = false)
     {
        $result = $this->connection->query($query, $types, $result_class, 
$result_wrap_class);
        if (MDB2::isError($result))


This fixes a lot, but it also introduces new problems:  Some tables have
'text' fields with no limit set. MDB2 maps those to 'clobs'; character large
objects. These are represented as a "resource", which is like a type of
stream from which you can read bytes like you would from a file.

Sven suggested fixing this by setting a limit on each of those text
fields, but I'm not sure that's a good idea since there is no intrinsic
reason that those fields should have a limit.  (and adding one could
introduce bugs)

Any ideas on how to proceed?

Cheers,
Peter Bex
Solide ICT - http://www.solide-ict.nl

_______________________________________________
Dev mailing list
[email protected]
http://lists.chamilo.org/listinfo/dev

Reply via email to