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

support for native sequence ( auto_increment ) using mysql 4.1.x ( mysqli )

Details

Request #3174support for native sequence ( auto_increment ) using mysql 4.1.x ( mysqli )
Submitted2005-01-12 15:25 UTC
Fromandrej at thenewline dot com
StatusClosed
PackageDB_DataObject
PHP Version5.0.2
OSirrelevant
Roadmaps(Not assigned)

Comments

[2005-01-12 15:25 UTC] andrej at thenewline dot com

Description:
------------
Hi,

I was wondering if you are gonna introduce support for native sequencies ( auto_increment ) when using DataObject with Mysql 4.1.x and above ( using mysqli extension ). Now it keeps creating *_seq tables even with 'dont_use_pear_sequences' turned off. I came up with this solution which worked for me just fine.

below are code chunks.

in first one i only added 'mysqli' as option for using native sequence

in the second i added the return of inserted rows ID for 'mysqli' case

i hope this helps in any way and hasn't been reported yet ( i have searched but didn't find such report ...)

bye

Andrej

Reproduce code:
---------------
DataObject.php [ lines 1841-1850; function sequenceKey() ]

if ( in_array($dbtype , array( 'mysql', 'mssql','mysqli')) && ($table[$usekey] & DB_DATAOBJECT_INT) && isset($realkeys[$usekey]) && ($realkeys[$usekey] == 'N')
) { ... }

DataObject.php [ lines 971-1011; function insert() ]

switch($dbtype){
case 'mysqli':
$this->$key = mysqli_insert_id(
$_DB_DATAOBJECT['CONNECTIONS'][$this->_database_dsn_md5]->connection );
break;
...
}