Skip to content
New issue

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

Does not support types normally #38

Closed
roquie opened this issue Dec 13, 2018 · 2 comments
Closed

Does not support types normally #38

roquie opened this issue Dec 13, 2018 · 2 comments

Comments

@roquie
Copy link

roquie commented Dec 13, 2018

How to reproduce?
0. Use postgresql

  1. Create table
CREATE TABLE test (
    id SERIAL PRIMARY KEY,
    boolfield Boolean not null,
);
  1. Execute queries
$con = Connection::fromPDO($this->PDO);
$db = new Database($con);
$db->insert(['boolfield' => true])->into('tree2'); // ok
$db->insert(['boolfield' => false])->into('tree2'); // type err, because PDO::PARAM_STRING used in the $stmt->execute() pdo method by default.
  1. Get the following errors
Database error.SQLSTATE[22P02]: Invalid text representation: 7 ERROR:  invalid input syntax for type boolean: \"\" [ INSERT INTO \"test\" (\"boolfield\") VALUES ('') ] 

The same bug as in Fluentpdo.

How fix it?
Work correctly with PHP types through PDO methods bindValue or bindParam like this:

$stmt->bindValues(1, $value, PDO::PARAM_BOOL);
@roquie roquie changed the title Does not support booleans normally Does not support types normally Dec 13, 2018
@roquie
Copy link
Author

roquie commented Dec 13, 2018

#39

@msarca
Copy link
Member

msarca commented Dec 13, 2018

Fixed in v.4.0.1, thanks

@msarca msarca closed this as completed Dec 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants