dbTalk Databases Forums  

[PHP] Overloaded stored procedures, PDO, and PHP issue

mailing.database.pgsql-php mailing.database.pgsql-php


Discuss [PHP] Overloaded stored procedures, PDO, and PHP issue in the mailing.database.pgsql-php forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Eric Chamberlain
 
Posts: n/a

Default [PHP] Overloaded stored procedures, PDO, and PHP issue - 08-19-2009 , 03:26 PM






--Apple-Mail-40--324054857
Content-Type: text/plain; charset="US-ASCII"; format=flowed; delsp=yes
Content-Transfer-Encoding: 7bit

I'm having an issue calling a specific stored proc using PHP and PDO.
I have two procs with the same name and same number of parameters.
However, the parameter types are different. When the below code is
called in PHP it always calls the varchar, varchar proc. I can not
get it to call the integer, varchar proc.

Stored procedure definitions:
boolean is_password_expired(i_user varchar, i_pass varchar)
boolean is_password_expired(i_user_id integer, i_pass varchar)

$stmt = $db->prepare("SELECT is_password_expired(?, ?)");
$stmt->bindValue(1, $userId, $hashPass, PDO::PARAM_INT);
$stmt->execute();

This always returns false because it's passing the $userId, of say
"1", to the varchar, varchar proc. I've tried using the following:

$stmt = $db->prepare("SELECT
is_password_expired(?::integer, ?::varchar)");

This completely fails.

$stmt->bindParam(1, $userId, $hashPass, PDO::PARAM_INT);

Same as bindValue result.

$stmt->execute(array($userId, $hashPass));

Same result.

Is there some way to inform PDO and Postgresql that I plan on using
the integer, varchar proc? If so, how do I do this? Thanks all!

Eric
--Apple-Mail-40--324054857
Content-Type: text/html; charset="US-ASCII"
Content-Transfer-Encoding: quoted-printable

<html><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: space; =
-webkit-line-break: after-white-space; "><div =
apple-content-edited=3D"true"><span class=3D"Apple-style-span" =
style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: medium; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; =
white-space: normal; widows: 2; word-spacing: 0px; =
-webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: =
0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><span class=3D"Apple-style-span" =
style=3D"border-collapse: separate; color: rgb(0, 0, 0); font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant: normal; =
font-weight: normal; letter-spacing: normal; line-height: normal; =
orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; =
widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; =
-webkit-border-vertical-spacing: 0px; =
-webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: =
auto; -webkit-text-stroke-width: 0px; "><div style=3D"word-wrap: =
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "><div><div><span class=3D"Apple-style-span" =
style=3D"font-size: medium; "><div>I'm having an issue calling a =
specific stored proc using PHP and PDO. &nbsp;I have two procs with the =
same name and same number of parameters. &nbsp;However, the parameter =
types are different. &nbsp;When the below code is called in PHP it =
always calls the varchar, varchar proc. &nbsp;I can not get it to call =
the integer, varchar proc.</div><div><br></div><div>Stored procedure =
definitions:</div><div>boolean is_password_expired(i_user varchar, =
i_pass varchar)</div><div>boolean is_password_expired(i_user_id integer, =
i_pass varchar)</div><div><br></div><div>$stmt =3D =
$db-&gt;prepare("SELECT is_password_expired(?, =
?)");</div><div>$stmt-&gt;bindValue(1, $userId, $hashPass, =
PDO::PARAM_INT);</div><div>$stmt-&gt;execute();</div><div><br></div><div>T=
his always returns false because it's passing the $userId, of say "1", =
to the varchar, varchar proc. &nbsp;I've tried using the =
following:</div><div><br></div><div>$stmt =3D $db-&gt;prepare("SELECT =
is_password_expired(?::integer, =
?::varchar)");</div><div><br></div><div>This completely =
fails.</div><div><br></div><div>$stmt-&gt;bindParam(1, $userId, =
$hashPass, PDO::PARAM_INT);</div><div><br></div><div>Same as bindValue =
result.</div><div><br></div><div>$stmt-&gt;execute(array($userId, =
$hashPass));</div><div><br></div><div>Same =
result.</div><div><br></div><div>Is there some way to inform PDO and =
Postgresql that I plan on using the integer, varchar proc? &nbsp;If so, =
how do I do this? &nbsp;Thanks =
all!</div><br></span>Eric</div></div></div></span></div></span></div></bod=
y></html>=

--Apple-Mail-40--324054857--

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.