php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #68037 SQLite3Stmt::bindValue() accepts numeric index parameters
Submitted: 2014-09-17 15:17 UTC Modified: 2017-01-28 12:45 UTC
Votes:3
Avg. Score:3.3 ± 1.7
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: benjamin dot morel at gmail dot com Assigned: cmb (profile)
Status: Closed Package: SQLite related
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: benjamin dot morel at gmail dot com
New email:
PHP Version: OS:

 

 [2014-09-17 15:17 UTC] benjamin dot morel at gmail dot com
Description:
------------
The doc for PDOStatement::bindValue(): http://php.net/manual/en/pdostatement.bindvalue.php

Says that $sql_param can only be a string:

public bool SQLite3Stmt::bindValue ( string $sql_param , mixed $value [, int $type ] )

> sql_param
> An string identifying the statement variable to which the value should be bound.

However, as the commenter said 4 years ago at the bottom of the page, it can also be an integer for "?" placeholders:

> Note that this also works with positional placeholders using the '?' token:

<?php

$stmt = $db->prepare('SELECT * FROM mytable WHERE foo = ? AND bar = ?');
$stmt->bindValue(1, 'somestring', SQLITE3_TEXT);
$stmt->bindValue(2, 42, SQLITE3_INTEGER);

?>

> Positional numbering starts at 1.

So basically it accepts both named parameters and numerically indexed parameters, just like PDO. It would be nice to add this fact to the documentation.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-28 12:45 UTC] cmb@php.net
-Status: Open +Status: Closed -Package: Documentation problem +Package: SQLite related -Assigned To: +Assigned To: cmb
 [2017-01-28 12:45 UTC] cmb@php.net
Note that PDOStatement and SQLite3Stmt are unrelated classes. I
assume that this bug report is about SQLite3Stmt (as PDOStatement
already stated `mixed` then this ticket has been filed), and as
such this issue is resolved with
<http://svn.php.net/viewvc?view=revision&revision=339509>.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 10 09:01:31 2024 UTC