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

Limit syntax fail #105

Open
konorlevich opened this issue Apr 14, 2019 · 1 comment
Open

Limit syntax fail #105

konorlevich opened this issue Apr 14, 2019 · 1 comment

Comments

@konorlevich
Copy link

konorlevich commented Apr 14, 2019

Reproduce

PHP 7.3.4-1+ubuntu18.04.1+deb.sury.org+3 (cli) (built: Apr 10 2019 10:51:11) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.4, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.4-1+ubuntu18.04.1+deb.sury.org+3, Copyright (c) 1999-2018, by Zend Technologies

nilportugues/sql-query-builder:1.7.0

$query = (new MysqlBuilder())
    ->select($tableName)
    ->orderBy('id', 'DESC')
    ->limit(1)
    ->end()
$sql = $bulder->writeFormatted($query);
$values = $bulder->getValues();
var_dump($sql, $values);
$stmt = (new PDO($dsn,$username,$password) )
    ->prepare($sql);
$stmt->execute($values);
var_dump($stmt->errorInfo()[2]);

Expected behavior

SELECT [...] LIMIT 1

Actual behavior

SELECT [...] LIMIT :v3, :v4"

array(4) {
[...]
[":v3"]=>
int(1)
[":v4"]=>
int(0)
}

string(154) "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''0', '1'' at line 1"

@alex-alicunde
Copy link

Use: $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE);

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