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

Prepared Statements don't work with DATETIME columns #119

Closed
bennnjamin opened this issue Aug 9, 2022 · 2 comments
Closed

Prepared Statements don't work with DATETIME columns #119

bennnjamin opened this issue Aug 9, 2022 · 2 comments
Labels

Comments

@bennnjamin
Copy link
Contributor

bennnjamin commented Aug 9, 2022

UPDATE: I have done some more testing and noticed that it works when I specify column names.

I have a very simple example that I'm testing v3 on with my own development database. The following code runs with no errors, but the result is empty since nothing is printed. If I use the db->query(...) function and don't use prepared statements, but instead pass values directly in the sql string it works. Any ideas how to troubleshoot this or any guidance on prepared statements would be greatly appreicated.

$email = "mytestemail";

$db = new MysqlConnectionPool(MysqlConfig::fromAuthority($host, $user, $pass, $database));

$stmt = $db->prepare("SELECT * FROM users WHERE email = ?");


$result = $stmt->execute([$email]);
foreach ($result as $row) {
    print_r($row);
}

$result2 = $db->execute("SELECT * FROM users WHERE email = ?", [$email]);
foreach ($result2 as $row) {
    print_r($row);
}
@bennnjamin bennnjamin changed the title Can't get prepared statements to work on v3 Select * doesn't work on tables with a lot of columns Aug 10, 2022
@bennnjamin bennnjamin changed the title Select * doesn't work on tables with a lot of columns Library doesn't work with DATETIME columns Aug 10, 2022
@bennnjamin bennnjamin changed the title Library doesn't work with DATETIME columns Prepared Statements don't work with DATETIME columns Aug 10, 2022
@bennnjamin
Copy link
Contributor Author

Turns out that any columns of type DATETIME, TIME, TIMESTAMP are not decoded properly, causing this issue.

@trowski
Copy link
Member

trowski commented Aug 10, 2022

Fixed via 3a2c329.

@trowski trowski closed this as completed Aug 10, 2022
@kelunik kelunik added the bug label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants