We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
The below is my code:
$sql = 'insert into my_table (name, amount) values (?, ?)' $params = array( 0 => "Messi", 1 => 100) $db->query($sql, $params);
$sql = 'insert into my_table (name, amount) values (?, ?)'
$params = array( 0 => "Messi", 1 => 100)
$db->query($sql, $params);
Then I check database and see that a new row inserted but with default values instead of my values.
Could you please correct me?
Thanks.
The text was updated successfully, but these errors were encountered:
I've not used this in a while but i think this is how it should be.
$sql = 'INSERT INTO my_table (name, amount) VALUES (?, ?)'; $params = array("Messi", 100); $db->query($sql, $params);
Sorry, something went wrong.
Thanks but it's same code. Still error.
Actually reviewing the source code it doesn't look to accept that method. Is there any reason you can't use the other method?
What about just plain PHP PDO prepare?
$prep = $dbh->prepare('INSERT INTO my_table (name, amount) VALUES (?, ?)'); $prep->execute(array('Messi', 100));
Yes, Seem this lib doest not support that. This is the bind function in DB.class.php in this lib:
DB.class.php
public function bind($para, $value) { $this->parameters[sizeof($this->parameters)] = [":" . $para , $value]; }
And I updated it to followings so that it works in my case:
public function bind($para, $value) { if (is_int($para)) { $this->parameters[sizeof($this->parameters)] = [++$para , $value]; } else { $this->parameters[sizeof($this->parameters)] = [":" . $para , $value]; } }
No branches or pull requests
Hi,
The below is my code:
$sql = 'insert into my_table (name, amount) values (?, ?)'
$params = array( 0 => "Messi", 1 => 100)
$db->query($sql, $params);
Then I check database and see that a new row inserted but with default values instead of my values.
Could you please correct me?
Thanks.
The text was updated successfully, but these errors were encountered: