I am developing a website using CI and mysql. i want to change date format from yyyy-mm-dd into dd-mm-yyyy. I know that i should use date_format function. But when I try to use it, it didn't work-the date format didn't change. Also i've try to add 2nd parameter(FALSE). but, I also found problem with that, especially, when i need to query more than 1 column. Here is my code:
function __construct() {
parent::__construct();
$this->table = array(
'name' => 'article',
'coloumn' => array(
'article_id',
'article_title',
'article_content',
'article_summary',
'date_format(article_publishdate, \'%d-%M-%Y %H:%i:%s\') as article_publishdate',
'article_source',
'article_link',
'media_type',
'media_link',
'media_position',
'article_category.category_title',
),
'join' => array(
0 => array('article_category' , 'article.article_category_id=article_category.category_id', 'left'),
),
'where' => array(),
'order' => array(),
'limit' => array(),
'idkey' => 'article_id',
);
}
public function getfullbody($id)
{
$this->db->query("update article set article_view = (article_view+1) where article_id = '$id'");
$this->db->select($this->table['column'], FALSE);
if (count($this->table['join'])>0){
foreach ($this->table['join'] as $row):
if (!empty($row[2])){
$this->db->join($row[0], $row[1], $row[2]);
}
else {
$this->db->join($row[0], $row[1]);
}
endforeach;
}
$this->db->where("article_id = '$id'");
$query = $this->db->get($this->table['name']);
$data = $query;
return $data;
}
Problem: when i use date_format() with codeigniter, it didn't change the date format. Then, how to fixed it? Thank you.
$this->table['coloumn']instead of$this->table['column']