$query = Model_Article::find() ->related('author') ->where('title', 'like', $search) ->or_where('summary', 'like', $search) ->or_where('body', 'like', $search);
$query = Model_Article::find() ->related('author') ->where('articles.title', 'like', '%' . $search .'%') ->or_where('articles.summary', 'like', '%' . $search .'%') ->or_where('articles.body', 'like', '%' . $search .'%') ->or_where('authors.name', 'like', '%' . $search .'%');
Harro Verton wrote on Friday 4th of May 2012:Eh? Articles is your main model, why prefix it? You asked the question about related models, articles is not a related model. where('title', 'like', ...) should do just fine. You only need the prefix for "author.name" to indicate name is a column in the related author model.
$query = Model_Article::find() ->related('author') ->where('title', 'like', '%' . $search .'%') ->or_where('summary', 'like', '%' . $search .'%') ->or_where('body', 'like', '%' . $search .'%') ->or_where('author.name', 'like', '%' . $search .'%') ->limit(Mypagination::$per_page) ->offset(Mypagination::$offset) ->get();
It looks like you're new here. If you want to get involved, click one of these buttons!