0

Answer:

I feel like a complete dummy =( I didn't realize it was adding a space at the end of the string in my code. After I rtrim the empty space from the string it all works.

I'm very sorry to have wasted everyones time =S


I came across an odd thing, here is an example:

This returns the correct result with no problems.

ORM::factory('blog_post')->where('title', 'like', 'this is my 1 post%')->find();

This however, doesn't return anything at all...

$post_title = 'this is my 1 post';
ORM::factory('blog_post')->where('title', 'like', $post_title.'%')->find();

And this doesn't either, even though the text is the same in all 3 examples

$post_title = 'this is my 1 post%';
ORM::factory('blog_post')->where('title', 'like', $post_title)->find();

Any ideas as to why?

Thank you very much for any help =)

Community
  • 1
  • 1
adamj
  • 4,672
  • 5
  • 49
  • 60

3 Answers3

1

try ORM::factory('blog_post')->where('title', 'like', '%'.$post_title.'%')->find();

UAMoto
  • 271
  • 3
  • 8
  • I forgot to mention that I tried this one as well with no luck =/ Thank you for your help. – adamj Nov 08 '12 at 05:41
1

The following syntax has to work.

ORM::Factory('foo')->where('bar' , 'like'  , '%'.$foobar.'%')->find();

if it is not working, please dump your variable and check the generated SQL.

Ene
  • 464
  • 2
  • 7
0

Try ORM::factory('blog_post')->load(null,null)->where('title', 'like', $post_title)->find();

woodle
  • 59
  • 5
  • This didn't work, apparently there is no such method called load in Kohana 3.2 ORM. Inregards to where the % stands, have a look at the examples I have at the top, I'm using the same text except I've placed it inside a variable and merely concatenated a % at the end. – adamj Nov 08 '12 at 05:39