Stored procedures, PDO, and PHP issue - Mailing list pgsql-php

From Eric Chamberlain
Subject Stored procedures, PDO, and PHP issue
Date
Msg-id A11E730E-82D7-4EE6-AD80-ECD95982D78A@zonarsystems.com
Whole thread Raw
Responses Re: Stored procedures, PDO, and PHP issue  (Andy Shellam <andy-lists@networkmail.eu>)
Re: Stored procedures, PDO, and PHP issue  (Bill Moran <wmoran@potentialtech.com>)
Re: Stored procedures, PDO, and PHP issue  ("Hajek, Nick" <Nick.Hajek@Vishay.com>)
List pgsql-php
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

pgsql-php by date:

Previous
From: Andreas Kalsch
Date:
Subject: Re: PDO does not trow Exceptions for queries
Next
From: Eric Chamberlain
Date:
Subject: Overloaded stored procedures, PDO, and PHP issue