Alright I have a GeneralModel written in CodeIgniter
and a friend asked me if I could convert it into Laravel 4.2
for him. I was working on this and I think I have most of it correct but I am getting stuck at the select statement.
In CodeIgniter
I have the following:
public function getData($table, $multiple = 1, $field = FALSE, $val = FALSE){
if($field != FALSE){
// WHERE in case of FIELD / VAL :)
$this->db->where($field, $val);
}
$query = $this->db->get($table);
if($multiple == 1){
// Multiple rows
return $query->result_array();
} else {
// One row
return $query->row_array();
}
}
Does anyone here knows how I can convert this function into Laravel 4.2
syntax?
I currently have:
public function getData($table, $multiple = 1, $field = FALSE, $val = FALSE){
$result = DB::table($table);
}
I got stuck pretty quickly since I have no idea how I can achieve the same in Laravel 4.2
with splitting up the sections of the query
like I did with CodeIgniter
.