cvs: pear /DB_DataObject DataObject.php
| From: | Alan Knowles | Date: | Tue, 16 Jan 2007 03:23:27 +0000 |
| Subject: | cvs: pear /DB_DataObject DataObject.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-44245@lists.php.net to get a copy of this message | ||
alan_k Tue Jan 16 03:23:27 2007 UTC
Modified files:
/pear/DB_DataObject DataObject.php
Log:
fix bug #9573 - enable disable_null_strings to turn of "null"-> NULL replacements
http://cvs.php.net/viewvc.cgi/pear/DB_DataObject/DataObject.php?r1=1.427&r2=1.428&diff_format=u
Index: pear/DB_DataObject/DataObject.php
diff -u pear/DB_DataObject/DataObject.php:1.427 pear/DB_DataObject/DataObject.php:1.428
--- pear/DB_DataObject/DataObject.php:1.427 Tue Jan 16 03:12:31 2007
+++ pear/DB_DataObject/DataObject.php Tue Jan 16 03:23:27 2007
@@ -15,7 +15,7 @@
* @author Alan Knowles <alan@akbkhome.com>
* @copyright 1997-2006 The PHP Group
* @license http://www.php.net/license/3_0.txt
PHP License 3.0
- * @version CVS: $Id: DataObject.php,v 1.427 2007/01/16 03:12:31 alan_k Exp $
+ * @version CVS: $Id: DataObject.php,v 1.428 2007/01/16 03:23:27 alan_k Exp $
* @link http://pear.php.net/package/DB_DataObject
*/
@@ -976,7 +976,7 @@
- if (is_string($this->$k) && (strtolower($this->$k) === 'null')
&& !($v & DB_DATAOBJECT_NOTNULL)) {
+ if (!isset($options['disable_null_strings']) &&
is_string($this->$k) && (strtolower($this->$k) === 'null') && !($v
& DB_DATAOBJECT_NOTNULL)) {
$rightq .= " NULL ";
continue;
}
@@ -1177,6 +1177,8 @@
$DB =
&$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
$dbtype = $DB->dsn["phptype"];
$quoteIdentifiers =
!empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
+ $options = $_DB_DATAOBJECT['CONFIG'];
+
foreach($items as $k => $v) {
if (!isset($this->$k)) {
@@ -1218,7 +1220,7 @@
}
// special values ... at least null is handled...
- if ((strtolower($this->$k) === 'null') && !($v &
DB_DATAOBJECT_NOTNULL)) {
+ if (!isset($options['disable_null_strings']) &&
(strtolower($this->$k) === 'null') && !($v & DB_DATAOBJECT_NOTNULL)) {
$settings .= "$kSql = NULL ";
continue;
}
@@ -2419,6 +2421,8 @@
$DB = &$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5];
$quoteIdentifiers =
!empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
+ $options = $_DB_DATAOBJECT['CONFIG'];
+
// if we dont have query vars.. - reset them.
if (!isset($this->_query)) {
$x = new DB_DataObject;
@@ -2465,7 +2469,7 @@
continue;
}
- if ((strtolower($this->$k) === 'null') && !($v &
DB_DATAOBJECT_NOTNULL)) {
+ if (!isset($options['disable_null_strings']) &&
(strtolower($this->$k) === 'null') && !($v & DB_DATAOBJECT_NOTNULL)) {
$this->whereAdd(" $kSql IS NULL");
continue;
}
@@ -3153,6 +3157,7 @@
}
$quoteIdentifiers =
!empty($_DB_DATAOBJECT['CONFIG']['quote_identifiers']);
+ $options = $_DB_DATAOBJECT['CONFIG'];
// not sure how portable adding database prefixes is..
$objTable = $quoteIdentifiers ?
@@ -3302,7 +3307,7 @@
$this->raiseError($value->getMessage() ,DB_DATAOBJECT_ERROR_INVALIDARG);
return false;
}
- if (strtolower($value) === 'null') {
+ if (!isset($options['disable_null_strings']) &&
strtolower($value) === 'null') {
$this->whereAdd("{$joinAs}.{$kSql} IS NULL");
continue;
} else {
@@ -3496,11 +3501,12 @@
*/
function validate()
{
+ global $_DB_DATAOBJECT;
require_once 'Validate.php';
$table = $this->table();
$ret = array();
$seq = $this->sequenceKey();
-
+ $options = $_DB_DATAOBJECT['CONFIG'];
foreach($table as $key => $val) {
@@ -3523,7 +3529,7 @@
}
- if (is_string($this->$key) && (strtolower($this->$key) ==
'null')) {
+ if (!isset($options['disable_null_strings']) &&
is_string($this->$key) && (strtolower($this->$key) == 'null')) {
if ($val & DB_DATAOBJECT_NOTNULL) {
$this->debug("'null' field used for '$key', but it
is defined as NOT NULL", 'VALIDATION', 4);
$ret[$key] = false;
@@ -3727,6 +3733,8 @@
function fromValue($col,$value)
{
+ global $_DB_DATAOBJECT;
+ $options = $_DB_DATAOBJECT['CONFIG'];
$cols = $this->table();
// dont know anything about this col..
if (!isset($cols[$col])) {
@@ -3736,13 +3744,13 @@
//echo "FROM VALUE $col, {$cols[$col]}, $value\n";
switch (true) {
// set to null and column is can be null...
- case ((strtolower($value) == 'null') && (!($cols[$col] &
DB_DATAOBJECT_NOTNULL))):
+ case (!isset($options['disable_null_strings']) && (strtolower($value)
== 'null') && (!($cols[$col] & DB_DATAOBJECT_NOTNULL))):
case (is_object($value) && is_a($value,'DB_DataObject_Cast')):
$this->$col = $value;
return true;
// fail on setting null on a not null field..
- case ((strtolower($value) == 'null') && ($cols[$col] &
DB_DATAOBJECT_NOTNULL)):
+ case (!isset($options['disable_null_strings']) && (strtolower($value)
== 'null') && ($cols[$col] & DB_DATAOBJECT_NOTNULL)):
return false;
case (($cols[$col] & DB_DATAOBJECT_DATE) && ($cols[$col] &
DB_DATAOBJECT_TIME)):