PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » Database » DB_DataObject » Bug #1631

insert auto_increment if

Details

Submitted2004-06-14 05:04 UTC
Frombonzie at fdns dot net
StatusBogus
PackageDB_DataObject
PHP Version4.3.4
OSLinux
Roadmaps(Not assigned)

Comments

[2004-06-14 05:04 UTC] bonzie at fdns dot net

Description:
------------
Attempting inserting new row, returns false when it should return the auto_increment_id..

- DataObject 1.6.1

----- DataObject Config Code ------------
$options = &PEAR::getStaticProperty('DB_DataObject','options');
$options = array(
'database' => $dsn,
'schema_location' => _APPBASEDIR . "/config/",
'class_location' => _APPBASEDIR . "/classes/dao/",
'require_prefix' => 'DataObjects/',
'class_prefix' => 'DAO_',
'extends_location' => "BDO.php",
'ignore_sequence_keys' => 'ALL',
'extends' => 'BDO',
'debug' => 0,
'debug_ignore_updates' => 0,
'dont_die' => 0,
);

Reproduce code:
---------------
include "Ad.php";

$Ad = new Ad();
$Ad->debugLevel(5);
$Ad->setactive("1");
$Ad->setname("test ad");
$Ad->settitle("test title ad");
$Ad->settext("text text text text");
$Ad->setlinked_to("C");
$Ad->setlinked_to_clientid(4);

$id = $Ad->insert();

if ($id == false) {
echo "dao returned false<br>";
}

echo "inserted: " . $id . "<Br>";

echo "read attempt 2: " . $Ad->getid() . "<Br>";

Expected result:
----------------
inserted: + auto_increment id returned from mysql.

Actual result:
--------------
ad: QUERY: INSERT INTO ad (active , name , title , text , linked_to , linked_to_clientid ) VALUES ('1' , 'test ad' , 'test title ad' , 'text text text text' , 'C' , 4 )
ad: query: QUERY DONE IN 0.0019571781158447 seconds
ad: 1: Clearing Cache for ad
dao returned false
inserted:
read attempt 2:

[2004-06-14 14:33 UTC] bonzie at fdns dot net

It turns out I had an error in the class that sits between the auto generated dataobject and db_dataobject class..