Not with any of the default methods, you'd have to use DB::expr() to do this, something along these lines (haven't tested it, but I think it'll work):met b wrote on Saturday 7th of January 2012:I wanted to know if it was possible to have a Model execute the following query: select * from table_name where concat_ws(' ',first_name,last_name) like '%c%'
$examples = Model_Example::query()->where(DB::expr('CONCAT_WS(" ", `first_name`, `last_name`)'), 'LIKE', '%c%')->get();
The second error is quite clear: there's no as_object() method on the result of execute(), thus that is invalid code. You can't call ->as_object() on the Database_Result_Cached object returned by execute(). As to the first error: first read up on security in Views. Everything that you don't mark as safe is encoded when you send it to the view, this is the case for database results as well as for any other data. Now database results are unmutable while they're in a result object, thus the encoding causes this error.met b wrote on Saturday 7th of January 2012:What's wrong with this code, plz? $data = DB::query('SELECT * FROM table_name')->as_object()->execute();
$this->response(View::forge('search/results', $data)); It gives me a the following error: Fuel\Core\FuelException [ Error ]: Database results are read-only
COREPATH/classes/database/result.php @ line 266 ...while $data = DB::query('SELECT * FROM table_name')->execute()->as_object();
$this->response(View::forge('search/results', $data)); gives me this: ErrorException [ Error ]: Call to undefined method Fuel\Core\Database_Result_Cached::as_object()
It looks like you're new here. If you want to get involved, click one of these buttons!