Re: numRows + oci8

From: Date: Tue, 02 Apr 2002 12:44:02 +0000
Subject: Re: numRows + oci8
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1078@lists.php.net to get a copy of this message
Ignat Ikryanov wrote: > > Tomas V.V.Cox <cox@idecnet.com> ïèøåò â > ñîîáùåíèè:3CA981DB.7059A2B8@idecnet.com... > > > > Oracle is not natively capable to get the number of rows from a result > > set. We have an emulation for it in PEAR DB in portability mode. Try it > > so: > > > > $db = DB::connect($dsn, array('persistent' => true, 'optimize' > > => > > 'portability')); > > <rest of code> > > Thanks for your help, but it has not helped me ;((((( > > I investigated this problem and has found the following: > > If in DB/oci8.php, > > function numRows($result) > { > // emulate numRows for Oracle. yuck. > if ($this->options['optimize'] == 'portability' && > $result === $this->last_stmt) { > $countquery = > preg_replace('/^\s*SELECT\s+(.*?)[,\s].*\s+FROM\s+/is', > 'SELECT COUNT(\1) FROM ', > $this->last_query); > $save_query = $this->last_query; > $save_stmt = $this->last_stmt; > $count = $this->query($countquery); > if (DB::isError($count) || > DB::isError($row = $count->fetchRow(DB_FETCHMODE_ORDERED))) > { > $this->last_query = $save_query; > $this->last_stmt = $save_stmt; > return $this->raiseError(DB_ERROR_NOT_CAPABLE); > } > return $row[0]; > } > return $this->raiseError(DB_ERROR_NOT_CAPABLE); > } > > change to: > > function numRows($result) > { > if ($this->options['optimize'] == 'portability' && > $result === $this->last_stmt) { > $countquery = preg_replace('/^SELECT(.*?)FROM/is', > 'SELECT COUNT(*) FROM ', > $this->last_query); > //^^^^^^^^I changed this line. > $save_query = $this->last_query; > $save_stmt = $this->last_stmt; > $count = $this->query($countquery); > if (DB::isError($count) || > DB::isError($row = $count->fetchRow(DB_FETCHMODE_ORDERED))) > { > $this->last_query = $save_query; > $this->last_stmt = $save_stmt; > return $this->raiseError(DB_ERROR_NOT_CAPABLE); > } > return $row[0]; > } > return $this->raiseError(DB_ERROR_NOT_CAPABLE); > } > > , all begins to work normally. > > Whether such replacement is correct? This change is correct and was commited to CVS long time ago. You should try to update your PEAR DB copy. Regards, Tomas V.V.Cox

« previous php.pear.general (#1078) next »