Overloaded stored procedures, PDO, and PHP issue

Overloaded stored procedures, PDO, and PHP issue

am 19.08.2009 22:26:08 von Eric Chamberlain

--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

-webkit-line-break: after-white-space; ">

apple-content-edited=3D"true"> 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; ">
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; "> 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; ">
break-word; -webkit-nbsp-mode: space; -webkit-line-break: =
after-white-space; ">
style=3D"font-size: medium; ">
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 =3D =
$db->prepare("SELECT is_password_expired(?, =
?)");
$stmt->bindValue(1, $userId, $hashPass, =
PDO::PARAM_INT);
$stmt->execute();

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

$stmt =3D $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
y>=

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