cvs: pear /MDB/MDB ibase.php oci8.php /MDB/tests MDB_bugs_testcase.php
| From: | Lukas Smith | Date: | Sat, 05 Feb 2005 12:40:21 +0000 |
| Subject: | cvs: pear /MDB/MDB ibase.php oci8.php /MDB/tests MDB_bugs_testcase.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-29145@lists.php.net to get a copy of this message | ||
lsmith Sat Feb 5 07:40:21 2005 EDT
Modified files:
/pear/MDB/MDB ibase.php oci8.php
/pear/MDB/tests MDB_bugs_testcase.php
Log:
- fix for bug #3146
http://cvs.php.net/diff.php/pear/MDB/MDB/ibase.php?r1=1.69&r2=1.70&ty=u
Index: pear/MDB/MDB/ibase.php
diff -u pear/MDB/MDB/ibase.php:1.69 pear/MDB/MDB/ibase.php:1.70
--- pear/MDB/MDB/ibase.php:1.69 Fri Oct 1 16:43:54 2004
+++ pear/MDB/MDB/ibase.php Sat Feb 5 07:40:20 2005
@@ -42,7 +42,7 @@
// | Author: Lorenzo Alberton <l.alberton@quipo.it> |
// +----------------------------------------------------------------------+
//
-// $Id: ibase.php,v 1.69 2004/10/01 20:43:54 lsmith Exp $
+// $Id: ibase.php,v 1.70 2005/02/05 12:40:20 lsmith Exp $
require_once 'MDB/Common.php';
@@ -829,7 +829,7 @@
max($this->highest_fetched_row[$result_value],
$this->current_row[$result_value]);
} else {
- ++$this->current_row[$result_value];
+ $this->current_row[$result_value] = $rownum;
}
if (isset($this->results[$result_value][$rownum])
&& $this->results[$result_value][$rownum]
http://cvs.php.net/diff.php/pear/MDB/MDB/oci8.php?r1=1.66&r2=1.67&ty=u
Index: pear/MDB/MDB/oci8.php
diff -u pear/MDB/MDB/oci8.php:1.66 pear/MDB/MDB/oci8.php:1.67
--- pear/MDB/MDB/oci8.php:1.66 Fri Oct 1 16:43:54 2004
+++ pear/MDB/MDB/oci8.php Sat Feb 5 07:40:20 2005
@@ -42,7 +42,7 @@
// | Author: Lukas Smith <smith@backendmedia.com> |
// +----------------------------------------------------------------------+
-// $Id: oci8.php,v 1.66 2004/10/01 20:43:54 lsmith Exp $
+// $Id: oci8.php,v 1.67 2005/02/05 12:40:20 lsmith Exp $
require_once('MDB/Common.php');
@@ -596,6 +596,7 @@
*/
function _executePreparedQuery($prepared_query, $query)
{
+ $this->last_query = $query;
$first = $this->first_selected_row;
$limit = $this->selected_row_limit;
$this->first_selected_row = $this->selected_row_limit = 0;
@@ -1598,7 +1599,7 @@
max($this->highest_fetched_row[$result_value],
$this->current_row[$result_value]);
} else {
- ++$this->current_row[$result_value];
+ $this->current_row[$result_value] = $rownum;
}
if (isset($this->results[$result_value][$rownum])
&& $this->results[$result_value][$rownum]
http://cvs.php.net/diff.php/pear/MDB/tests/MDB_bugs_testcase.php?r1=1.15&r2=1.16&ty=u
Index: pear/MDB/tests/MDB_bugs_testcase.php
diff -u pear/MDB/tests/MDB_bugs_testcase.php:1.15 pear/MDB/tests/MDB_bugs_testcase.php:1.16
--- pear/MDB/tests/MDB_bugs_testcase.php:1.15 Fri Oct 1 16:43:57 2004
+++ pear/MDB/tests/MDB_bugs_testcase.php Sat Feb 5 07:40:21 2005
@@ -122,6 +122,21 @@
}
}
+ function verifyFetchedValues(&$result, $rownum, &$data) {
+ $row = $this->db->fetchInto($result, null, $rownum);
+ for ($i = 0; $i < count($this->fields); $i++) {
+ $type = $this->types[$i];
+ if ($this->types[$i] == 'float') {
+ $delta = 0.0000000001;
+ } else {
+ $delta = 0;
+ }
+ $value = $row[$i];
+ $field = $this->fields[$i];
+ $this->assertEquals($data[$field], $value, "the value retrieved for field
\"$field\" ($value) using type $type doesn't match what was stored
($data[$field]).", $delta);
+ }
+ }
+
/**
*
*/
@@ -329,6 +344,47 @@
$this->db->freeResult($result);
}
+
+ /**
+ * http://pear.php.net/bugs/bug.php?id=3146
+ */
+ function testBug3146() {
+ $data = array();
+ $total_rows = 5;
+
+ $prepared_query = $this->db->prepareQuery('INSERT INTO users (user_name,
user_password, subscribed, user_id, quota, weight, access_date, access_time, approved) VALUES (?, ?,
?, ?, ?, ?, ?, ?, ?)', $this->types);
+
+ for ($row = 0; $row < $total_rows; $row++) {
+ $data[$row]['user_name'] = "user_$row";
+ $data[$row]['user_password'] = 'somepassword';
+ $data[$row]['subscribed'] = (boolean)($row % 2);
+ $data[$row]['user_id'] = $row;
+ $data[$row]['quota'] = sprintf("%.2f",strval(1+($row+1)/100));
+ $data[$row]['weight'] = sqrt($row);
+ $data[$row]['access_date'] = MDB_Date::mdbToday();
+ $data[$row]['access_time'] = MDB_Date::mdbTime();
+ $data[$row]['approved'] = MDB_Date::mdbNow();
+
+ $this->insertTestValues($prepared_query, $data[$row]);
+
+ $result = $this->db->executeQuery($prepared_query);
+ if (MDB::isError($result)) {
+ $this->assertTrue(false, 'Error executing prepared
query'.$result->getMessage());
+ }
+ }
+ $this->db->freePreparedQuery($prepared_query);
+
+ $result = $this->db->query('SELECT user_name, user_password, subscribed,
user_id, quota, weight, access_date, access_time, approved FROM users ORDER BY user_id',
$this->types);
+
+ $numrows = $this->db->numRows($result);
+
+ $this->verifyFetchedValues($result, 0, $data[0]);
+ $this->verifyFetchedValues($result, 2, $data[2]);
+ $this->verifyFetchedValues($result, null, $data[3]);
+ $this->verifyFetchedValues($result, 1, $data[1]);
+
+ $this->db->freeResult($result);
+ }
}
?>
\ No newline at end of file