[TYPO3-mvc] $query->like() replaces operand with "?"
Søren Malling
soren.malling at gmail.com
Mon May 31 14:53:38 CEST 2010
Hi Jochen,
So true, the use of array in the argument solved the issue.
Better start opening my eyes when reading through the API :)
Once again, thanks for all your help!
Regards,
Søren
On Mon, May 31, 2010 at 2:36 PM, Jochen Rau <jochen.rau at typoplanet.de> wrote:
> Hi Søren.
>
> On 31.05.10 13:25, Søren Malling wrote:
>>
>> Hi,
>>
>> I got the following query object
>>
>> public function findByTelephoneAndName($searchQuery) {
>> $query = $this->createQuery();
>> $query = $query->matching(
>> $query->logicalOr(
>>
>> $query->like('firstname', (string)'%'.$searchQuery.'%')
>> #
>> $query->like('lastname', '%'.$searchQuery.'%')
>> #
>> $query->like('telephone', '%'.$searchQuery.'%')
>> )
>> )->setLimit((integer) 10);
>> return $query->execute();
>> }
>>
>> but no matter how I insert the $searchQuery variable the statement is
>> returned as
>>
>> .... where fe_users.tx_ext_field LIKE ? ...
>>
>> even if I replace the variable with a static string.
>
> I assume that you have debugged before the ? was replaced by the prepared
> value in line 225 of Typo3DbBackend. just uncomment line 226 to debug the
> statement.
>
> The method logicalOr() expects two Constraints or an array of Constraints.
> You can also strip off "(string)" ans "(integer)":
>
> $query = $this->createQuery();
> $query = $query->matching(
> $query->logicalOr(
> array(
> $query->like('firstname', '%' . $searchQuery . '%'),
> $query->like('lastname', '%' . $searchQuery . '%'),
> $query->like('telephone', '%' . $searchQuery . '%')
> )
> )
> );
> $query->setLimit(10);
> return $query->execute();
>
>
> should work.
>
> Regards
> Jochen
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
--
Certified TYPO3 Integrator
More information about the TYPO3-project-typo3v4mvc
mailing list