Join with 'LIKE' operator and 'OR' operator in where query

Join with 'LIKE' operator and 'OR' operator in where query

nidedinidedi Posts: 13Questions: 1Answers: 0
edited June 2013 in Editor
1. I would like to know if there is a posibility to use the 'LIKE' operator in a join instance:
[code]
->join(Join::inst('keywords', 'object')
->join('string1', 'string2')
[/code]
if I have string1 'something' and string2 'something more', can I join the parent and child table using the mysql LIKE operator?


2. Use 'OR' operator in where query
from docs: [quote] Where query - multiple conditions are bound as ANDs. [/quote]
If I have this case:
[code]
$out = $editor
->where('id_kw', '1', '=')
->where('id_url', '1', '=')
[/code]
can this be translated in a similar mysql query 'WHERE id_kw = 1 OR id_url = 1' or it's possible only using the 'AND' operator?

Replies

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    At the moment it is only possible to use = and AND I'm sorry to say. Having said that, it is possible to modify the libraries to do what you are looking for. If you have a look in Join.php at line 419, that is the block where the Join class actually does the join. It should be possible to change the logic condition there. I like the idea of exposing this in the API and I'll look at that for future releases.

    Regarding the second point, that also would require a code change. In Editor.php the function `_get_where` is what combines the where conditions. It would be possible to modify that to use `or_where()` etc. Again, I like the idea of exposing this, perhaps as a fourth parameter in the Editor `where()` method.

    I hope this helps a bit, and thanks for the feedback!

    Allan
  • nidedinidedi Posts: 13Questions: 1Answers: 0
    Thank you again for the short and clear answer!

    I will look into changing the classes as you mentioned and I am glad that you are considering adding this options into a future release.

    Great work!
This discussion has been closed.