[eluser]jon29[/eluser]
hi i'm converting one of my sites from procedural php to codeigniter and having trouble when i use LEFT to restrict number of characters returned, query runs fine but as it returns an array key of LEFT(content, 220) i can't access it as normal in the views section again then same problem with the date,
could someone offer advice on the best way round this please?
Code:
function newspreview()
{
$sql = "SELECT id, title, LEFT(content, 20), DATE_FORMAT(date, '%d-%m-%Y') FROM newsletter ORDER BY date DESC LIMIT 3" ;
$q = $this->db->query($sql);
if($q->num_rows() > 0) {
foreach ($q->result_array() as $row) {
$data[] = $row;
}
return $data;
}
}
returns
Array ( [0] => Array (
[id] => 4
[title] => Page
[LEFT(content, 20)] => What are pleased to a
[DATE_FORMAT(date, '%d-%m-%Y')] => 12-01-2012
)
any advice very much appreciated thanks