oop - PHP - PDO placeholder with table.column format -
i created function preparevalue() takes array formatted $column => $value, , replaces each value ? whilst preserving copy of original array binding , executing later pdo.
this works fine queries following
$a = [ 'company' => 'apple' 'item' => 'ipad' ]; preparevalue($a); $sql = 'where company = ? , item = ?'; prepare($sql); execute($a);
however, required write queries array value table.column type value, pdo doesnt seem being substituted placeholder.
$a = [ 'companyid' => 'itemid'; ] preparevalue($a); $sql = 'where companyid = ?'; prepare($sql); execute($a);
this query not work, if replace ? manually itemid following
where companyid = itemid
the query works fine.
what best in scenario this? perhaps there way prepare table.column type values?
Comments
Post a Comment