PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Database » DB_DataObject » Bug #3764

PostgreSQL Boolean Doesn't Work

Details

Submitted2005-03-10 14:38 UTC
Fromsdteffen at gmail dot com
Assignedalan_k
StatusClosed
PackageDB_DataObject
PHP Version4.3.10
OSWindows XP Professional
Roadmaps(Not assigned)

Comments

[2005-03-10 14:38 UTC] sdteffen at gmail dot com

Description:
------------
Using bool fields in PostgreSQL will not work with
FormBuilder.
Using FormBuilder 0.12.1 and DataObject 1.7.7

Reproduce code:
---------------
The solution is to change two lines in the processForm()
function of FormBuilder.php (around line 2130) - simply
0 has to be replaced with false:
************************************************
foreach ($this->booleanFields as $boolField) {
if (!isset($values[$boolField])) {
$this->_do->$boolField = false;
}
}
foreach ($tableFields as $field => $type) {
if ($type & DB_DATAOBJECT_BOOL && !isset($values[$field])) {
$this->_do->$field = false;
}
}
************************************************
In addition, I have to use the following code in my DataObject class:

function preGenerateForm(&$this) {
$elements = $this->_do->table();
foreach ($elements as $key => $type) {
if($type & DB_DATAOBJECT_BOOL) {
$this->_do->$key = ('t' == $this->_do->$key ? 1 : 0);
}
}
}

Expected result:
----------------
Bool fields of PostgreSQL databases should be displayed
properly and saved properly.

Actual result:
--------------
Bool fields of PostgreSQL databases are always displayed
true in the form - even if they're false in the
database. It is not possible to save bool values in PostgreSQL
databases (1 or 0 are send to the database instead of
the correct values 't' or 'f'