[TYPO3-core] RFC #15457: Add support for prepared queries [summary and pending questions]

Ernesto Baschny [cron IT] ernst at cron-it.de
Thu Aug 19 19:58:33 CEST 2010


Helmut Hummel schrieb am 19.08.2010 19:22:

> On 19.08.10 15:42, Ernesto Baschny [cron IT] wrote:
>> if (is_bool($value)) {
>>   $type = self::PARAM_BOOL;
>> } elseif (t3lib_div::testInt($value)) {
>>   $type = self::PARAM_INT;
>> } elseif (is_null($value) || strtoupper($value) === 'NULL') {
>>   $type = self::PARAM_NULL;
>> } else {
>>   $type = self::PARAM_STR;
>> }
>>
>> So pretty easy to understand and document. Only concearn might be
>> "testInt()", which allows also strings that looks like integer ('1' =>
>> 1). I would not oppose to change that to is_int() to have it more strict.
> 
> That's exactly what I thought, too. I would also prefer to change this
> to is_int(), the we have a clean behaviour of PARAM_AUTOTYPE converting
> PHP types into DBMS types. When leaving testInt(), it would introduce
> some additional "magic" which might be unwanted. E.g. quering for a zip
> code '01234', which is a string value in the database and passed as PHP
> string would be converted to integer 1234, if the PARAM_STR is not
> expicitly passed when binding the value.

Xavier, if you don't have anything against it, could we agree on that
minor follow-up, as the new API is still fresh?

So magic also on "NULL", else we won't be able to write "NULL" string to
the DB:

if (is_bool($value)) {
   $type = self::PARAM_BOOL;
} elseif (is_int($value)) {
   $type = self::PARAM_INT;
} elseif (is_null($value)) {
   $type = self::PARAM_NULL;
} else {
   $type = self::PARAM_STR;
}

Agreed?

Cheers,
Ernesto


More information about the TYPO3-team-core mailing list