logo       

Re: DataObject: Ignoring key definitions: msg#00352

php.pear.general

Subject: Re: DataObject: Ignoring key definitions

have a read through

http://cvs.php.net/diff.php/pear/DB_DataObject/DataObject.php?r1=1.153&r2=1.154&ty=u

basically - to override the default guessed autoincrement, you need to override the sequenceKey() method :

eg.
dont use sequence keys at all..
function sequenceKey() { return (false,false); }

use DB's sequence keys (eg. $db->nextval())
function sequenceKey() { return ('id',false); }


use native autoincrement or nextvals()
function sequenceKey() { return ('id',true); }

Regards
Alan


Alan Knowles wrote:
I will look at this in the next few days - the whole sequence/key code is very complex and needs desperatly simplifying...

It may involve an overhall of the keys code:
> [crosstable__keys]
> table1_id = 2 == recognized autoincrement or nextval key
> table2_id = 1 == normal primary key or unique's

in which case :
- insert should use autoinc keys..
- update/delete should use any of them which are set..

if the generator fails to guess the autoincrement, then overriding the keys() method is the prefered way to fix this (no more ignore_sequence_keys etc...)

I may also introduce
realdbtype = mssql
so you can use the identiy code with odbc


Thoughts.....

Regards
Alan







Markus Wolff wrote:

Hi there,

I got a classic cross-linking table in my database looking like this:

- table1_id: part of primary key and also foreign key to table1
- table2_id: part of primary key and also foreign key to table2

In my database.ini, this will write the following entries:
[crosstable__keys]
table1_id = 1
table2_id = 1

Problem is, when I do an INSERT on this table, table1_id will be treated as an auto_increment primary key and will not be included in the INSERT statement.

I tried to solve this in the config file using:
ignore_sequence_keys = crosstable

Didn't work.

Then I tried to go into the crosstable class and redefine the keys() method:
function keys()
{
return array();
}

No success either.

The only thing that helped was uncommenting the key definitions from the config file - but this will of course be overwritten on the next createTables run.

I must admit I haven't tried the latest package release yet - is this a known bug or are there other workarounds that I've missed?

CU
Markus





--
Can you help out?
Need Consulting Services or Know of a Job?
http://www.akbkhome.com

--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise