2010-11-19 41 views

回答

3

你必须使用核心mysql函数SUBSTRING来实现这一点。

CI中的查询可以写成 -

$this->db->select("SUBSTRING('COLUMN_NAME',5)"); 

$query = $this->db->get('TABLE_NAME'); 

foreach ($query->result() as $row) 
{ 
    //process result here. 
} 
0

太晚了,但是这是对像我在寻找解决方案

public function getDetails(){ 
    // mytable(id,name,about,...,status) 
    $this->db->select(array('id', 'name', 'SUBSTRING(about,1,180) AS about', 'status')); 
    $result=$this->get('mytable');   
    return result_array(); 
}