Re: Prepared statements

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

 



Anthony Ettinger wrote:
> On 3/6/06, Anthony Ettinger <aettinger@xxxxxxxxxxxxxx> wrote:
>   
>> On 3/6/06, Julius Hacker <julius@xxxxxxxxxxxxxx> wrote:
>>     
>>> Curt Zirzow wrote:
>>>       
>>>> I assume your loop is something like:
>>>>   while(condition) {
>>>>     $auction_parts['id'] = 'some value';
>>>>     $auction_parts['name'] = 'some value';
>>>>     ...
>>>>     $insert->execute();
>>>>   }
>>>>
>>>>         
>>> Yes, thats it.
>>>
>>>       
>>>> My first guess would be, if not aleady done, initialize
>>>> $auction_parts before you do your bind_param() with something like:
>>>>
>>>>   $auction_parts = array('id' => null, 'name' => null, ...);
>>>>   $insert->bind_param("issdsis", $auction_house["id"], ...);
>>>>
>>>>         
>>> Unfortunately it helps nothing :-(
>>> But I think also that it's something because of the declaration and
>>> initalization of the variables because it works if I have the bind_param
>>> in the loop after I gave the variables their values.
>>> But to have the bind_param in the loop isn't the best solution I think.
>>>
>>> --
>>> Regards
>>> Julius Hacker
>>>
>>> http://www.julius-hacker.de
>>> julius@xxxxxxxxxxxxxx
>>>
>>> OpenPGP-Key-ID: 0x4B4A486E
>>>
>>> --
>>> PHP General Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>>
>>>       
>> $stmt = $mysqli->prepare("INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)");
>> $stmt->bind_param('sssd', $code, $language, $official, $percent);
>>
>> $code = 'DEU';
>> $language = 'Bavarian';
>> $official = "F";
>> $percent = 11.2;
>>
>> /* execute prepared statement */
>> $stmt->execute();
>>
>> http://us2.php.net/manual/en/function.mysqli-stmt-bind-param.php
>>
>>     
>
>
> Table 1. Type specification chars
> Character	Description
> i	corresponding variable has type integer
> d	corresponding variable has type double
> s	corresponding variable has type string
> b	corresponding variable is a blob and will be send in packets
>
>
> 'sssd' defines the datatypes of the 4 arguments you're passing in.
>
>   
I know the example ;-)
I checked the statement now without the loop, but defined the variables
also after the bind_param.
Very interesting is that it works if I write $auction_parts["..."] =
"..."; but that it doesn't if I write $auction_parts = array("..." =>
"...", ...);

--
Regards
Julius Hacker

http://www.julius-hacker.de
julius@xxxxxxxxxxxxxx

OpenPGP-Key-ID: 0x4B4A486E

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux