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 #5348

doesn't insert data without .ini configuration

Details

Submitted2005-09-09 10:10 UTC
Fromffullone at gmail dot com
StatusNo Feedback
PackageDB_DataObject
PHP Version4.4.0
OSwindows xp
Roadmaps(Not assigned)

Comments

[2005-09-09 10:10 UTC] ffullone at gmail dot com

Description:
------------
DB_DO doesn't insert a new value in a table without the use of the ini configuration file (using features described here http://pear.php.net/manual/en/package.database.db-dataobject.intro-autobuilding.php#AEN25718 ).

Btw if I force sequenceKey then the insert works.

Note that the table has the id with the auto_increment flag on

Test script:
---------------
class DataObjects_User extends DB_DataObject
{
var $id;
var $username;
var $password;
var $sid;

function __clone() { return $this; }
function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_User',$k,$v); }

function DataObjects_User()
{

$db['users']['table'] = 'users';
$db['users']['column'] = array
(
'id' => DB_DATAOBJECT_INT,
'username' => DB_DATAOBJECT_STR,
'password' => DB_DATAOBJECT_STR,
'sid' => DB_DATAOBJECT_STR
);
$db['users']['keys'] = array('id');

$this->tableName($db['users']['table']);
$this->table($db['users']['column']);
$this->keys($db['users']['keys']);

//if sequenceKey is disabled doesn't work
//$this->sequenceKey('id',true);

}

}

$a = new DataObject_User();
$a->username = 'pippo';
$a->password = md5('pippo');
if ($a->insert())
{
echo "hurrĂ ";
}
else
{
echo "booooo";
}

Expected result:
----------------
the record is inserted

OUTPUT:

hurrĂ !

Actual result:
--------------
without the $this->sequenceKey('id',true);

OUTPUT

booooo

[2005-11-13 14:37 UTC] andrew at andrewshell dot org

I am having this problem as well. The error is in function sequenceKeys. There is a line $realkeys = $_DB_DATAOBJECT['INI'][$this->_database][$this->__table."__keys"]; that if you are not using an ini file this data doesn't exist, it throws a notice and the insert doesn't work. I have an example at http://andrewshell.org/bugs/DB_DataObject_Bug_1.rar