Commit ad6be874 by Trần Văn Minh

Thêm slug khi thêm mới

parent bf846aa6
...@@ -135,6 +135,7 @@ class CmsTrack extends CI_Controller ...@@ -135,6 +135,7 @@ class CmsTrack extends CI_Controller
} }
} }
//Thêm bài hát mới
public function addTrack() public function addTrack()
{ {
$this->_data['list_user'] = $list_user = $this->track_model->getListUsers(); $this->_data['list_user'] = $list_user = $this->track_model->getListUsers();
...@@ -196,6 +197,7 @@ class CmsTrack extends CI_Controller ...@@ -196,6 +197,7 @@ class CmsTrack extends CI_Controller
$nct_id = $this->input->post('nct_id'); $nct_id = $this->input->post('nct_id');
if($title){ if($title){
$slug = MyHelper::genSlug($title);
$dataUpdate = array( $dataUpdate = array(
'title' => $title, 'title' => $title,
'userid' => $artist, 'userid' => $artist,
...@@ -203,6 +205,7 @@ class CmsTrack extends CI_Controller ...@@ -203,6 +205,7 @@ class CmsTrack extends CI_Controller
'link_nct' => ($source == 'nct')? $link : '', 'link_nct' => ($source == 'nct')? $link : '',
'link_keeng' => ($source == 'keeng')? $link : '', 'link_keeng' => ($source == 'keeng')? $link : '',
'id_nct' => $nct_id, 'id_nct' => $nct_id,
'slug' => $slug,
'tag' => 'vmusic', 'tag' => 'vmusic',
'genre' => 1, 'genre' => 1,
'time' => time() 'time' => time()
......
...@@ -84,11 +84,11 @@ class Track_model extends CI_Model ...@@ -84,11 +84,11 @@ class Track_model extends CI_Model
} }
if ($active == 'insert') { if ($active == 'insert') {
$this->db->set('track_id', $id_track); $this->db->set('track_id', $id_track);
$this->db->insert('track_user'); $this->db->insert($this->track_user);
} else { } else {
$this->db->where('track_id', $id_track); $this->db->where('track_id', $id_track);
$this->db->where('id', $id); $this->db->where('id', $id);
$this->db->update('track_user'); $this->db->update($this->track_user);
} }
} }
...@@ -99,7 +99,7 @@ class Track_model extends CI_Model ...@@ -99,7 +99,7 @@ class Track_model extends CI_Model
track_artists.name AS artist, track_artists.name AS artist,
track_artists.id AS id_track_artist'); track_artists.id AS id_track_artist');
$this->db->from($this->_table); $this->db->from($this->_table);
$this->db->join('track_user', 'track_user.track_id = tracks.id', 'left'); $this->db->join($this->track_user, 'track_user.track_id = tracks.id', 'left');
$this->db->join($this->track_artists, 'track_artists.track_id = tracks.id', 'left'); $this->db->join($this->track_artists, 'track_artists.track_id = tracks.id', 'left');
$this->db->where($this->_table . '.id', $id); $this->db->where($this->_table . '.id', $id);
$query = $this->db->get(); $query = $this->db->get();
...@@ -166,7 +166,7 @@ class Track_model extends CI_Model ...@@ -166,7 +166,7 @@ class Track_model extends CI_Model
track_user.name AS singer_name2, track_user.id AS id_user, track_user.name AS singer_name2, track_user.id AS id_user,
track_artists.name AS composer_name2, track_artists.id AS id_artist'); track_artists.name AS composer_name2, track_artists.id AS id_artist');
$this->db->from($this->_table); $this->db->from($this->_table);
$this->db->join('track_user', 'track_user.track_id = tracks.id', 'left'); $this->db->join($this->track_user, 'track_user.track_id = tracks.id', 'left');
$this->db->join($this->track_artists, 'track_artists.track_id = tracks.id', 'left'); $this->db->join($this->track_artists, 'track_artists.track_id = tracks.id', 'left');
$this->db->join('users u1', 'u1.id = track_user.user_id', 'left'); $this->db->join('users u1', 'u1.id = track_user.user_id', 'left');
$this->db->join('users u2', 'u2.id = track_artists.user_id', 'left'); $this->db->join('users u2', 'u2.id = track_artists.user_id', 'left');
...@@ -263,7 +263,7 @@ class Track_model extends CI_Model ...@@ -263,7 +263,7 @@ class Track_model extends CI_Model
//if ($query) $users = $query->result_array(); //if ($query) $users = $query->result_array();
//return $users; //return $users;
$this->db->from('track_user'); $this->db->from($this->track_user);
$this->db->where('track_id =', $track_id); $this->db->where('track_id =', $track_id);
$query = $this->db->get(); $query = $this->db->get();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment