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

Incorrect Sql Expression parameters when passing zero in the constructor #6

Closed
2 tasks done
weierophinney opened this issue Dec 31, 2019 · 2 comments
Closed
2 tasks done

Comments

@weierophinney
Copy link
Member

I am trying to create an expression that has zero as the parameter value. However, the parameters incorrectly show as empty.

Code to reproduce the issue

$expr = new \Zend\Db\Sql\Expression('?', '0');
print_r($expr->getParameters());

Expected results

It prints "0"

Actual results

It prints empty array

Proposed fix

https://github.com/zendframework/zend-db/blob/master/src/Sql/Expression.php#L59

In Zend\Db\Sql\Expression, update the constructor to explicitly check for '0' when setting parameters

if ($parameters || $parameters === '0') {
     $this->setParameters($parameters);
}

Originally posted by @albertor24 at zendframework/zend-db#381

@weierophinney
Copy link
Member Author

@albertor24 Please submit PR and add test to cover your case 👍


Originally posted by @michalbundyra at zendframework/zend-db#381 (comment)

@samsonasik
Copy link
Member

I seems already fixed. I tried it:

➜  laminas-db git:(master) php -a
Interactive shell

php > include 'vendor/autoload.php';
php > $expr = new \Zend\Db\Sql\Expression('?', '0');
php > print_r($expr->getParameters());
0

I'm closing it.

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