For example,
I have an ORM set up like below.
$test = new Model_Test();
$test_result = $test->find_all();
foreach ($test_result as $tmp) :
// i would like to truncate the the $tmp->name and put it back to $test ORM like
$test->name = truncate($tmp->name, 20);
endforeach;
I would like to truncate the ORM result before passing to view. How can we do that?
Help appreciated!
thanks,
This is actually quite easy thanks to the get()
method in Kohana's ORM module. You can have a script as simple as
class Model_Test extends ORM
{
protected $_stringLength = 20;
public function get($column)
{
$value = parent::get($column);
if (is_string($value))
return substr($value, 0, $this->_stringLength);
else
return $value;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.