* @author Alan Knowles <alan@akbkhome.com>
* @copyright 1997-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
- * @version CVS: $Id: DataObject.php 329992 2013-04-03 11:38:43Z alan_k $
+ * @version CVS: $Id: DataObject.php 320069 2011-11-28 04:34:08Z alan_k $
* @link http://pear.php.net/package/DB_DataObject
*/
* @access private
* @var string
*/
- var $_DB_DataObject_version = "1.11.0";
+ var $_DB_DataObject_version = "1.11.3";
/**
* The Database table (used by table extends)
// Ignore variables which aren't set to a value
- if ( !isset($this->$k) && $ignore_null) {
+ if ( (!isset($this->$k) || ($v == 1 && $this->$k == ''))
+ && $ignore_null
+ ) {
continue;
}
// dont insert data into mysql timestamps
$this->raiseError("update: trying to perform an update without
the key set, and argument to update is not
DB_DATAOBJECT_WHEREADD_ONLY
- ", DB_DATAOBJECT_ERROR_INVALIDARGS);
+ ". print_r(array('seq' => $seq , 'keys'=>$keys), true), DB_DATAOBJECT_ERROR_INVALIDARGS);
return false;
}
} else {
|| !is_string($options['disable_null_strings'])
|| strtolower($options['disable_null_strings']) !== 'full' ;
-
+
foreach($items as $k => $v) {
- if (!isset($this->$k) && $ignore_null) {
- continue;
+ if ((!isset($this->$k) || ($v == 1 && $this->$k == ''))
+ && $ignore_null
+ ) {
+ continue;
}
// ignore stuff thats
// - V2 may store additional data about float/int
$settings .= "$kSql = " . intval($this->$k) . ' ';
}
-
+
if (!empty($_DB_DATAOBJECT['CONFIG']['debug'])) {
$this->debug("got keys as ".serialize($keys),3);
}
- if (strtoupper($string) == 'BEGIN') {
+ if (
+ strtoupper($string) == 'BEGIN' ||
+ strtoupper($string) == 'START TRANSACTION'
+ ) {
if ($_DB_driver == 'DB') {
$DB->autoCommit(false);
$DB->simpleQuery('BEGIN');
}
return true;
}
+
if (strtoupper($string) == 'COMMIT') {
$res = $DB->commit();
if ($_DB_driver == 'DB') {
}
// apply our filtered version, which excludes the distinct column.
- $selectAs = empty($cols) ? array() : array(array( $cols , '%s', false)) ;
+ $selectAs = empty($cols) ? array() : array(array(array( $cols) , '%s', false)) ;
if ($has_distinct) {
$this->selectAdd($has_distinct);
}
-
- foreach($selectAs as $ar) {
-
+
+ foreach($selectAs as $ar) {
$this->selectAs($ar[0], $ar[1], $ar[2]);
}
// restore links..
$case[strtolower($k)] = $k;
}
if ((substr(phpversion(),0,1) == 5) && isset($case[strtolower($element)])) {
- file_put_contents('/tmp/backtrace', var_export(debug_backtrace(),true));
trigger_error("PHP5 set/get calls should match the case of the variable",E_USER_WARNING);
$element = strtolower($element);
}
/**
* Last Error that has occured
* - use $this->_lastError or
- * $last_error = &PEAR::getStaticProperty('DB_DataObject','lastError');
+ * $last_error = PEAR::getStaticProperty('DB_DataObject','lastError');
*
* @access public
* @var object PEAR_Error (or false)
if ($behaviour == PEAR_ERROR_DIE && !empty($_DB_DATAOBJECT['CONFIG']['dont_die'])) {
$behaviour = null;
}
- $error = PEAR::getStaticProperty('DB_DataObject','lastError');
+
+ $error = &PEAR::getStaticProperty('DB_DataObject','lastError');
// no checks for production here?....... - we log errors before we throw them.
if (is_array($this->_link_loaded)) {
foreach ($this->_link_loaded as $do) {
- $do->free();
+ if (
+ !empty($this->{$do}) &&
+ is_object($this->{$do}) &&
+ method_exists($this->{$do}, 'free')
+ ) {
+ $this->{$do}->free();
+ }
}
}
* @author Alan Knowles <alan@akbkhome.com>
* @copyright 1997-2006 The PHP Group
* @license http://www.php.net/license/3_01.txt PHP License 3.01
- * @version CVS: $Id: Generator.php 327926 2012-10-08 02:42:09Z alan_k $
+ * @version CVS: $Id: Generator.php 315531 2011-08-26 02:21:29Z alan_k $
* @link http://pear.php.net/package/DB_DataObject
*/
$defs = $__DB->tableInfo($quotedTable);
} else {
$defs = $__DB->reverse->tableInfo($quotedTable);
+ if (PEAR::isError($defs)) {
+ return $defs;
+ }
foreach ($defs as $k => $v) {
if (!isset($defs[$k]['length'])) {
continue;
}
}
-
-
-
if (PEAR::isError($defs)) {
return $defs;
- }
+ }
+
+
+
if (@$_DB_DATAOBJECT['CONFIG']['debug'] > 2) {
$this->debug("getting def for $database/$table",'fillTable');
$this->debug(print_r($defs,true),'defs');