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

bindParam doesn't use type and leng informations #8

Closed
gcollombet opened this issue Jul 28, 2015 · 6 comments
Closed

bindParam doesn't use type and leng informations #8

gcollombet opened this issue Jul 28, 2015 · 6 comments

Comments

@gcollombet
Copy link

bindParam doesn't use type and leng informations.
This cause an issue when you bind an OUT param with an undifined php variable. For exemple if your OUT param is defined as an integer in your stored procedure, you will get a char with the lefmost digit of the real result number after you execute the statement. (sorry for my english, i'm French).

@taq
Copy link
Owner

taq commented Jul 28, 2015

What's the result of the regular PDOOCI implementation?

@gcollombet
Copy link
Author

It work's fine with the regular PDOOCI implementation. You get a proper int as a result.

@taq
Copy link
Owner

taq commented Jul 28, 2015

Could you please change, on Statement.php:

\oci_bind_by_name($this->_stmt, $param, $value);

to

\oci_bind_by_name($this->_stmt, $param, $value, $leng, $type);

and see if it works? Or provide a test to check the desired behaviour?

@gcollombet
Copy link
Author

Ok, thank you. I'll try that and provide a test.

@taq
Copy link
Owner

taq commented Jul 28, 2015

Thanks. :-)

@taq
Copy link
Owner

taq commented Aug 8, 2015

We really need to run tests. I just made the change I told above and everything broke. We really need to send the default expected values, so:

bindParam expects:

  1. parameter
  2. variable
  3. optional data type, defaults to PDO::PARAM_STR
  4. optional lenght, defaults to ... nothing, or null!

oci_bind_by_name expects:

  1. statement
  2. name
  3. variable
  4. length, defaults to -1
  5. type, defaults to SQLT_CHR

Then I changed again the code sending PDO::PARAM_STR and -1 as default values, and it broke again. Then I created an if checking if length and type were not null (need both because the last optional on bindParam is length, so type would be filled even with null), if so, they are send to oci_bind_by_name (on inverse order, duh!), and seems it worked on the way that didn't broke tests and previous behaviours. I'll commit on the next minutes so you can test if it worked.

taq added a commit that referenced this issue Aug 8, 2015
@taq taq closed this as completed Feb 12, 2016
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