yajra / pdo-via-oci8

PHP PDO_OCI functions via OCI8 extension
Other
88 stars 61 forks source link

bindParam using wrong number when using ? in statement #64

Closed istaveren closed 5 years ago

istaveren commented 5 years ago

bindParam using wrong param number when using ?

When you try to bind params with ? the first one should be 1 not 0.

Code snippet of problem

$stmt = $this->con->prepare('INSERT INTO person (name) VALUES (?)');
$var = 'Joop';
$stmt->bindParam(1, $var, PDO::PARAM_STR);
yajra commented 5 years ago

I didn't know bindParams can work like that? 😄 Will check the PR again once the conflict was resolved.

BTW, if possible, can you please create another PR for this issue. #63 is getting bigger and might be hard to rollback just in case there are some breaking changes that we might missed. Thanks!

istaveren commented 5 years ago

Please check it. I put all the needed fixes in my branch.

Next time I will create different branches per issue.

yajra commented 5 years ago

Upon further review, it appears that this syntax is not yet supported because we are mapping bindParam to oci_bind_by_name which requires a colon-prefixed bind variable placeholder.

istaveren commented 5 years ago

That will also work. But if it is an int it should start with 1.