Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D3DDB63256C for ; Wed, 19 Aug 2009 17:57:10 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 24718-08 for ; Wed, 19 Aug 2009 20:56:55 +0000 (UTC) X-Greylist: delayed 00:12:32.507964 by SQLgrey-1.7.6 Received: from smtp-gw3.mailanyone.net (unknown [208.101.34.33]) by mail.postgresql.org (Postfix) with ESMTP id E0D1E63248B for ; Wed, 19 Aug 2009 17:56:59 -0300 (ADT) Received: from smtp-gw51.mailanyone.net ([208.70.128.77]) by smtp-gw3.mailanyone.net with esmtp (Exim 4.69) (envelope-from ) id 1Mds1A-00010h-Tf for pgsql-php@postgresql.org; Wed, 19 Aug 2009 15:44:24 -0500 Received: from mailanyone.net by smtp-gw51.mailanyone.net with esmtpa (MailAnyone extSMTP andy@networkmail.eu) id 1Mds12-0007tE-4U; Wed, 19 Aug 2009 15:44:17 -0500 Message-ID: <4A8C6432.2050500@networkmail.eu> Date: Wed, 19 Aug 2009 21:44:34 +0100 From: Andy Shellam User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 To: Eric Chamberlain CC: pgsql-php@postgresql.org Subject: Re: Stored procedures, PDO, and PHP issue References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.499 tagged_above=-10 required=5 tests=BAYES_00=-2.599, RDNS_NONE=0.1 X-Spam-Level: X-Archive-Number: 200908/11 X-Sequence-Number: 4052 Hi Eric, What about setting your SQL text to use $1 and $2 as the parameter values? I'm currently doing this in the C API (as I type this!) so not sure if this will work in PHP PDO. $stmt = $db->prepare("SELECT is_password_expired($1::integer, $2::varchar)"); When you say "this completely fails" - in what respect? What errors do you get? Also have you tried making sure your PHP $userId is an integer not a string - e.g. settype($userId, 'integer'); Again I'm not sure if this has a bearing on the PDO stuff as I've never used it. Regards, Andy Eric Chamberlain wrote: > 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 >