I need to write a question use Magento ORM applying functions at condition like this:

SELECT * WHERE REPLACE(street, ' ', '') = 'Streetac'.

I try using regular expressions but I have problem with case sensitive.

I need a function like this: addExpressionFieldToSelect, but I need to use this function at condition.

In that the query return all this cases.

'House 12' = 'hOuse 12' = 'house 12 ' = HouSe 12 '

  • I don't understand what do you want to do.. You want that request like "SELECT * FROM table WHERE condition = mycondition" where mycondition can be "House 12" or "hOuse 12" or "house 12" or "HouSe 12".. ? – Kozame Dec 8 '17 at 14:21
  • The query must return that the field with this values this cases: 'House 12' = 'hOuse 12' = 'house 12 ' = HouSe 12 ' are equels. – user59428 Dec 8 '17 at 14:58
  • My problem is with the withspaces if I have a lot of whitespeces at the end or between the words at the string and I need that the query were insensitive. – user59428 Dec 8 '17 at 15:02
  • May be you can use UPPER() function for mysql, so all your cases 'House 12', 'hOuse 12', 'house 12 ', ' HouSe 12 ' will be change to 'HOUSE 12' for the comparison (and so bypass the case). For the whitespaces, you can use your replace. – Kozame Dec 8 '17 at 16:00
  • Yes I try this but the problem its that magento ORM dont allow to apply sql functions at sql conditions. The query its envolved into ` ` for this reason the UPPER() function when magento excecute the sql query the condition its excecuted into: "UPPER(fieldname)". I need to do this with magento ORM I not allowed to use a query directly . – user59428 Dec 8 '17 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.