Currently I am writing a website using Kohana framework 3.3. Today, I wanted to create subpage where user would be able to browse news, however I encountered a small problem with Kohana ORM.
I would like to retrieve only a dozen / several dozen characters from a text field, because loading the entire field would be a significant waste of server resources.
Does anyone know how I can achieve the same effect as in those cases?
- ↓ MySQL/SQL retrieve first 40 characters of a text field?
- (preffered) http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_left
- How to select only some characters from MySQL field?
Thanks in advance for your answers.
This isn't possible with the ORM class. You can build your own query with Kohana's own query builder and the object can be returned as an ORM-model, therefore you fill in your ORM model name (e.g. 'my_orm_model') in the as_object function.
Combining one of your suggested links with Kohana's own Query builder you would get something like this.