Skip to content

Commit

Permalink
- disabled 1-indexing in bindParam() and bindColumn() until its absol…
Browse files Browse the repository at this point in the history
…utely clear that PDO will stay this way

git-svn-id: http://svn.php.net/repository/pear/packages/MDB2/trunk@185279 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Lukas Smith committed Apr 27, 2005
1 parent 4d042c0 commit 0d20729
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 2 additions & 2 deletions MDB2.php
Original file line number Diff line number Diff line change
Expand Up @@ -2842,7 +2842,7 @@ function getResource()
function bindColumn($column, &$value, $type = null)
{
if (is_numeric($column)) {
--$column;
// todo --$column;
} else {
$column_names = $this->getColumnNames();
if ($this->db->options['portability'] & MDB2_PORTABILITY_LOWERCASE) {
Expand Down Expand Up @@ -2969,7 +2969,7 @@ function MDB2_Statement_Common(&$db, &$statement, $query, $types, $result_types)
function bindParam($parameter, &$value, $type = null)
{
if (is_numeric($parameter)) {
--$parameter;
// todo --$parameter;
} else {
$parameter = preg_replace('/^:(.*)$/', '\\1', $parameter);
}
Expand Down
1 change: 0 additions & 1 deletion package.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
- ensure that types are numerically keyed in setResultTypes()
- added caching to getColumnNames()
- added bindColumn() support
- made bindParam() 1-indexed for numeric parameters (as PDO does; BC break!)
EOT;

$description =<<<EOT
Expand Down
2 changes: 1 addition & 1 deletion tests/MDB2_bugs_testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function clearTables() {

function insertTestValues(&$stmt, &$data) {
for ($i = 0; $i < count($this->fields); $i++) {
$stmt->bindParam($i+1, $data[$this->fields[$i]]);
$stmt->bindParam($i, $data[$this->fields[$i]]);
}
}

Expand Down
10 changes: 5 additions & 5 deletions tests/MDB2_usage_testcase.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function supported($feature) {

function insertTestValues(&$stmt, &$data) {
for ($i = 0; $i < count($this->fields); $i++) {
$stmt->bindParam($i+1, $data[$this->fields[$i]]);
$stmt->bindParam($i, $data[$this->fields[$i]]);
}
}

Expand Down Expand Up @@ -349,7 +349,7 @@ function testPreparedQueries() {
$stmt = $this->db->prepare("INSERT INTO users (user_name, user_password, user_id) VALUES (?, $question_value, 1)", array('text'));

$value = 'Sure!';
$stmt->bindParam(1, $value);
$stmt->bindParam(0, $value);

$result = $stmt->execute();

Expand Down Expand Up @@ -809,8 +809,8 @@ function testAffectedRows() {
for ($row = 0; $row < $total_rows; $row++) {
$password = "another_password_$row";
if ($row == 0) {
$stmt->bindParam(1, $password);
$stmt->bindParam(2, $row);
$stmt->bindParam(0, $password);
$stmt->bindParam(1, $row);
}

$result = $stmt->execute();
Expand All @@ -827,7 +827,7 @@ function testAffectedRows() {
$stmt = $this->db->prepare('DELETE FROM users WHERE user_id >= ?', array('integer'));

$row = intval($total_rows / 2);
$stmt->bindParam(1, $row);
$stmt->bindParam(0, $row);
for ($row = $total_rows; $total_rows; $total_rows = $row) {
$row = intval($total_rows / 2);

Expand Down

0 comments on commit 0d20729

Please sign in to comment.