Re: MySQL stored procedures OUT or INOUT parameters
| From: | Post-No-Reply TUDBC | Date: | Fri, 10 Oct 2008 23:08:49 +0000 |
| Subject: | Re: MySQL stored procedures OUT or INOUT parameters | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-45511@lists.php.net to get a copy of this message | ||
By using TUDBC (http://www.tudbc.org), you can call stored procedures
easily. Better yet, it works on any flavors of PHP (original,
Phalanger, or Quercus). Even better, you would use the same style of
coding for any DBMSes or programming languages. Have fun!
For an example in MySQL (just change the connection string for other DBMSes),
TestSumOut(IN x int, IN y int, OUT total int)
The PHP codes (using EZ Style) are
$vault = new
TUDBCConnectionVaultSingle("tudbc:mysqli://localhost//tudbcguest,helloworld/tudbcdemo");
$conn = $vault->getConnection();
$ezsql = $conn->getSQL_EZ(
"call TestSumOut(<*<?int:x>*>, <*<?int:y>*>,
<*<??int:total>*>)",
"TestSumOutSprocSQL");
$ezsql->getStatement()->parameterSetValues($x, $y);
$result = $ezsql->getStatement()->executeUpdate();
$total = $ezsql->getStatement()->sprocGetOutputParameter(2)->getInt();
$ezsql->close();
$conn->close();
$vault->close();
You will find other examples in the demo codes on the website.
TUDBC
Below is the declaration of the example stored procedure
DELIMITER $$
DROP PROCEDURE IF EXISTS TestSumOut` $$
CREATE PROCEDURE
TestSumOut(x int, y int, OUT total int )
BEGIN
set total = x + y;
END $$
DELIMITER;
On 9/19/08, "Stanisław T. Findeisen" <stf@eisenbits.homelinux.net> wrote:
> Thodoris wrote:
>
> > I think that the manual is quite clear on this:
> >
> > http://dev.mysql.com/doc/refman/5.1/en/call.html
> >
> > You use a way to query the database like PDO or mysqli and you wite sql.
> >
>
> Yes, I've already found that multi-step way before... I was just wondering
> if anything got better since with regard to this.
>
> Apparently not.
>
> STF
>
> =======================================================================
> http://eisenbits.homelinux.net/~stf/ . My PGP key
> fingerprint is:
> 9D25 3D89 75F1 DF1D F434 25D7 E87F A1B9 B80F 8062
> =======================================================================
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>