I am using Laravel 4 and the Eloquent model for the project we are working on. The database matches 3NF and everything works fine. Also, all MySQL tables were transferred back from InnoDB to MyISAM, since the version of MySQL is <5.6 (full-text search in InnoDB is only supported with 5.6 and higher).
When creating some database search filters, I find a lack using the Eloquent model and Query Builder. In particular, especially when trying to perform a full text search on columns from multiple tables (and stay in the context of the Eloquent object).
For simplicity, we have the following database structure:
( ) , , ( projects).
if (Request::isMethod('post'))
{
$filters = array('type_id','status','division','date_of_activation','date_of_closure');
foreach ($filters as $filter) {
$value = Input::get($filter);
if (!empty($value) && $value != -1) {
$projects->where($filter,'=',$value);
}
}
$search = Input::get('search');
if (!empty($search)) {
$projects->whereRAW("MATCH(name,description) AGAINST(? IN BOOLEAN MODE)",array($search));
}
}
return View::make('pages/projects/listView',
array(
"projects" => $projects->paginate(10)
)
);
, - projects.name, projects.description notes.note.
, Eloquent, Query Builder , , /:
- Query Builder , Eloquent . , , Eloquent. Eloquent
Project::find($id) , . - "where",
, . ,
"" "Query Builder" .
- ,
"".
Laravel API, SQL- Eloquent. whereRAW(), . , , .
, :
- , Eloquent. , , Query Builder.
- , Query Builder Eloquent? (
Project::find($id) ). - , , Eloquent Query Builder
where , get() paginate(10) .
, Eloquent Query Builder - . Eloquent SQL-, , Eloquent . Query Builder Laravel.
, , / Laravel , , !
, , :)