Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conditional bindings based on parameter value #21

Open
DaveWilcock opened this issue May 22, 2014 · 0 comments
Open

Conditional bindings based on parameter value #21

DaveWilcock opened this issue May 22, 2014 · 0 comments

Comments

@DaveWilcock
Copy link

This is an enhancement request to implement conditional bindings.

This feature would consider the parameter value; if found to be null, would throw the binding away, if not, would attach the defined arbitrary SQL to the relevant portion of the SQL.

A suggested solution to this may be as follows:

<?php
$arr_records = $obj_db->prepare("SELECT * FROM myTable WHERE col1= ?col1 AND col2 = ?col2 ?_cond_col3 order by xxx")
         ->bindIntIfNotNull('cond_col3', "AND col3 = ?", $col3)
         ->bindInt('col1', $col1)
         ->bindInt('col2', $col2)
         ->fetchAll();
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant