diff --git a/app/modules/meta/models/data_model.php b/app/modules/meta/models/data_model.php index 0d8041c..1c5c255 100644 --- a/app/modules/meta/models/data_model.php +++ b/app/modules/meta/models/data_model.php @@ -280,27 +280,6 @@ class data_model extends \miniMVC\Model { // ! Data Retrieval // -------------------------------------------------------------------------- - /** - * Get the id of the last item of the type - * - * @param string $type - * @return int - */ - public function get_last_id($type) - { - $query = $this->db->select('id') - ->from($type) - ->order_by('id', 'DESC') - ->limit(1) - ->get(); - - $r = $query->fetch(\PDO::FETCH_ASSOC); - - return $r['id']; - } - - // -------------------------------------------------------------------------- - /** * Get breadcrumb data for section * @@ -364,26 +343,6 @@ class data_model extends \miniMVC\Model { // -------------------------------------------------------------------------- - /** - * Gets the name of the category from its id - * - * @param int - * @return string - */ - public function get_category_by_id($id) - { - $query = $this->db->select('category') - ->from('category') - ->where('id', (int) $id) - ->get(); - - $row = $query->fetch(\PDO::FETCH_ASSOC); - - return $row['category']; - } - - // -------------------------------------------------------------------------- - /** * Get the genre name by category id * @@ -405,46 +364,6 @@ class data_model extends \miniMVC\Model { // -------------------------------------------------------------------------- - /** - * Gets the name of the section from its id - * - * @param int - * @return string - */ - public function get_section_by_id($id) - { - $query = $this->db->select('section') - ->from('section') - ->where('id', (int) $id) - ->get(); - - $row = $query->fetch(\PDO::FETCH_ASSOC); - - return $row['section']; - } - - // -------------------------------------------------------------------------- - - /** - * Gets the data for the specified id - * - * @param int $id - * @return array - */ - public function get_data_by_id($id) - { - $query = $this->db->select('key, value') - ->from('data') - ->where('id', (int) $id) - ->get(); - - $row = $query->fetch(\PDO::FETCH_ASSOC); - - return $row; - } - - // -------------------------------------------------------------------------- - /** * Get the categories for the specified genre * @@ -470,6 +389,26 @@ class data_model extends \miniMVC\Model { // -------------------------------------------------------------------------- + /** + * Gets the name of the category from its id + * + * @param int + * @return string + */ + public function get_category_by_id($id) + { + $query = $this->db->select('category') + ->from('category') + ->where('id', (int) $id) + ->get(); + + $row = $query->fetch(\PDO::FETCH_ASSOC); + + return $row['category']; + } + + // -------------------------------------------------------------------------- + /** * Get the sections for the specified category id * @@ -496,7 +435,27 @@ class data_model extends \miniMVC\Model { // -------------------------------------------------------------------------- /** - * Get the data fro the section + * Gets the name of the section from its id + * + * @param int + * @return string + */ + public function get_section_by_id($id) + { + $query = $this->db->select('section') + ->from('section') + ->where('id', (int) $id) + ->get(); + + $row = $query->fetch(\PDO::FETCH_ASSOC); + + return $row['section']; + } + + // -------------------------------------------------------------------------- + + /** + * Get the data from the section * * @param int * @return array @@ -520,6 +479,26 @@ class data_model extends \miniMVC\Model { // -------------------------------------------------------------------------- + /** + * Gets the data for the specified id + * + * @param int $id + * @return array + */ + public function get_data_by_id($id) + { + $query = $this->db->select('key, value') + ->from('data') + ->where('id', (int) $id) + ->get(); + + $row = $query->fetch(\PDO::FETCH_ASSOC); + + return $row; + } + + // -------------------------------------------------------------------------- + /** * Get sections and data for a general data outline * @@ -551,7 +530,7 @@ class data_model extends \miniMVC\Model { while($row = $d_query->fetch(\PDO::FETCH_ASSOC)) { - $d_array[$row['section_id']][$row['key']] = $row['value']; + $d_array[$row['section_id']][$row['id']] = array($row['key'] => $row['value']); } } @@ -658,6 +637,29 @@ class data_model extends \miniMVC\Model { return in_array(strtolower($str), $valid); } + // -------------------------------------------------------------------------- + + /** + * Get the id of the last item of the type + * + * @param string $type + * @return int + */ + public function get_last_id($type) + { + $query = $this->db->select('id') + ->from($type) + ->order_by('id', 'DESC') + ->limit(1) + ->get(); + + $r = $query->fetch(\PDO::FETCH_ASSOC); + + return $r['id']; + } + + // -------------------------------------------------------------------------- + } // End of data_model.php \ No newline at end of file diff --git a/app/modules/meta/views/category_detail.php b/app/modules/meta/views/category_detail.php index e44b3bc..8bf3609 100644 --- a/app/modules/meta/views/category_detail.php +++ b/app/modules/meta/views/category_detail.php @@ -1,10 +1,8 @@ -

- -
" method="post"> +" method="post">
Add Section
@@ -17,7 +15,8 @@
- + +

Sections