Skip site navigation (1) Skip section navigation (2)

Re: Stored procedures, PDO, and PHP issue

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: Eric Chamberlain <Eric(dot)Chamberlain(at)zonarsystems(dot)com>
Cc: <pgsql-php(at)postgresql(dot)org>
Subject: Re: Stored procedures, PDO, and PHP issue
Date: 2009-08-19 21:11:27
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-php
In response to Eric Chamberlain <Eric(dot)Chamberlain(at)zonarsystems(dot)com>:

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

I would expect what you're doing to work.  It works with the functional

What do the query logs on the server say?  Try turning full query logging
on and see what's actually getting run.

I see in another reply that you're getting a blank white screen.  This
tends to suggest that your debugging is configured wrong, or that PHP is
encountering a fatal error and coredumping or something similar.  Check
whatever logs are appropriate for evidence of this.  Check the HTTP error
log, as well as system error logs.

Bill Moran

In response to

pgsql-php by date

Next:From: Andy ShellamDate: 2009-08-19 21:15:41
Subject: Re: Stored procedures, PDO, and PHP issue
Previous:From: Eric ChamberlainDate: 2009-08-19 20:58:04
Subject: Re: Stored procedures, PDO, and PHP issue

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group