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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
20 + 6 = ?
Subscribe to this entry?

 
 [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 Apr 26 13:01:28 2024 UTC