Re: Cant get Mysql stored procedure to work.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/7/13 Patrick Moloney <webpat52@xxxxxxxxx>:
> Bastien Koert wrote:
>>
>> On Mon, Jul 13, 2009 at 1:33 PM, Patrick Moloney<webpat52@xxxxxxxxx>
>> wrote:
>>>
>>> Bastien Koert wrote:
>>>>
>>>> On Mon, Jul 13, 2009 at 11:52 AM, Patrick Moloney<webpat52@xxxxxxxxx>
>>>> wrote:
>>>>>
>>>>> I've had no success trying to execute any stored procedure from php.
>>>>> I'm just trying to follow the example for multi-query in the php
>>>>> manual,
>>>>> and
>>>>> have tried an example from Artfulsoftware.com. I have one input and one
>>>>> output parameter. I've simplified the stored procedure to always output
>>>>> one
>>>>> value from one record, regardless of the value passed in.
>>>>> The SP works in Mysql. Just cant run it from php. It returns False.
>>>>> I look at the query log in mysql and it calls the stored procedure, and
>>>>> shows the input value and output variable. No further information. I'm
>>>>> not
>>>>> familiar with that log so I don't know what it should look like.
>>>>> The only thing I see looks like a brief reference to UTC8 - but I don't
>>>>> think I am (intentionally) using that anywhere. I get no other error
>>>>> back
>>>>> or
>>>>> logged. I'm using root as the user, which is the only defined user.
>>>>> Should
>>>>> this work, or are stored procedures not working well?
>>>>>
>>>>> --
>>>>> PHP Database Mailing List (http://www.php.net/)
>>>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>>>
>>>>>
>>>> Can you show the php code?
>>>>
>>> Below is the relevant code. The database connection is established, but
>>> the
>>> query call returns False. The call is recorded in the mysql query log. No
>>> error there or returned, but just False. Proc works in mysql and  ignores
>>> the value of the input parameter and returns 1 string. But I can't get it
>>> to
>>> do that from php.
>>>
>>>
>>>   @$db = new mysqli('localhost', 'root', 'password', 'Sales');
>>>   if (mysqli_connect_errno())
>>>   { echo 'Error: could not connect to database. ';
>>>     exit;
>>>   }
>>>
>>>   $brandrequest = 'x';
>>>   $res = $db->multi_query( "CALL myproc($brandrequest, ModelID); "  );
>>>   if (!$res ) {
>>>     echo 'No Listings were found for this request.';
>>>     echo mysql_error();
>>>     exit;
>>>   }
>>>
>>>
>>> --
>>> PHP Database Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>> Is the multi_query call the correct one?
>>
>
> I did work with mysqli_multi_query also. The documentation seemed to confuse
> the two. The only examples were like I have above.
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

If your stored procedure has in and out parameters, maybe the
mysqli::prepare() method may be of more use.

-- 
-----
Richard Quadling
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
"Standing on the shoulders of some very clever giants!"
ZOPA : http://uk.zopa.com/member/RQuadling

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux