MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Filipe Freitas Date:November 27 2006 5:12pm
Subject:Re: Calling Stored Procedures from PHP
View as plain text  
Chris White wrote:
> On Monday 27 November 2006 07:59, Filipe Freitas wrote:
>   
>> Hi,
>>
>> This is not a mysql thing but maybe you can help me.
>> I want to call a stored procedure from PHP, so I tried it like normal
>> querys: mysql_query("CALL mySP();"); with no success.
>>
>> thx
>>     
>
> No success how?  Generally with stored procedures and returning values, you 
> use a session variable and utilize it as OUT like so:
>
> DROP PROCEDURE IF EXISTS CURVAL $
> CREATE PROCEDURE CURVAL (OUT current INT)
> BEGIN
> 	SELECT value INTO current FROM sequence;
> END $
> DELIMITER ;
>
> so when I go to call curval:
>
> CALL CURVAL(@cur)
>
> and the value can be received by:
>
> SELECT @cur;
>
>
>   
My stored procedure is the following:

CREATE PROCEDURE `getListaDeNewsflashes`(in quantidade smallint)
   COMMENT 'Devolve uma tabela com um número limite de  newsflashes'
begin
PREPARE statement FROM "SELECT * FROM newsflashes ORDER BY RAND() LIMIT ?";
SET @limit=quantidade;
EXECUTE statement USING @limit;
end

it works when I execute it on mysql monitor: call 
getListaDeNewsflashes(10);
in php it doesn't. I think I need the out session variable like you 
said. But how? I  will need a variable for every column?
Thread
Calling Stored Procedures from PHPFilipe Freitas27 Nov
  • Re: Calling Stored Procedures from PHPRolando Edwards27 Nov
  • Re: Calling Stored Procedures from PHPChris White27 Nov
    • Re: Calling Stored Procedures from PHPFilipe Freitas27 Nov
      • Re: Calling Stored Procedures from PHPChris White28 Nov
        • Re: Calling Stored Procedures from PHPFilipe Freitas28 Nov
          • SELECT...GROUP BY WITHIN GROUP BYKerry Frater28 Nov
            • Re: SELECT...GROUP BY WITHIN GROUP BYddevaudreuil28 Nov
              • RE: SELECT...GROUP BY WITHIN GROUP BYKerry Frater28 Nov
              • RE: SELECT...GROUP BY WITHIN GROUP BYKerry Frater30 Nov
  • Re: Calling Stored Procedures from PHPMike Kruckenberg27 Nov
  • Re: Calling Stored Procedures from PHPRemo Tex28 Nov
Re: Calling Stored Procedures from PHPdpgirago28 Nov