RE: [PEAR-DEV] oci8.php huge bug

From: Date: Thu, 09 May 2002 12:54:55 +0000
Subject: RE: [PEAR-DEV] oci8.php huge bug
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6019@lists.php.net to get a copy of this message
> Am I to understand I can not use such sequences with PEAR::DB? No, you don't. > It is up to the coder to know the name of his sequences, not up to the > abstaction layer. > I could understand if such a workaround existed in the createSequence() > method, but why does it exist in the nextID() method? A sequence is an independant entitie on OCI, does not exists on mysql 3.xx by ex., and for this reason, the name do not have to get the same name as a existing table. The goals is to make your code works with most of db as possible. DB creators make this choice. > I am not sure if a database system exists that insists on _seq naming > convention, but even if it does, this does not mean that all need this > convention. > This method cripples the abstraction layer because I am not able > to use it > How abstract is that? "..." :) please do not start the monthly thread ( ok manuel ? :))) ) You have two solutions, maybe Stig got ideas about others ways ? - the "clean" way : $res = $db->query("SELECT $myseqname.nextval FROM dual"); - Patch oci8.php ( ) function nextId($seq_name, $ondemand = true, $portability=false) { $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); $repeat = 0; do { $this->expectError(DB_ERROR_NOSUCHTABLE); if ( $portability) $result = $this->query("SELECT ${sqn}_seq.nextval FROM dual"); else $result = $this->query("SELECT ${sqn.nextval FROM dual"); ..... } // }}} // {{{ createSequence() function createSequence($seq_name, $portability=false) { $sqn = preg_replace('/[^a-z0-9_]/i', '_', $seq_name); if ( $portability ) return $this->query("CREATE SEQUENCE ${sqn}_seq"); else return $this->query("CREATE SEQUENCE ${sqn}"); } pa

« previous php.pear.dev (#6019) next »