Advertisement
dropbox1349

ajax_model.php

Feb 12th, 2015
629
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.77 KB | None | 0 0
  1. <?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3.  * Eye View Design CMS module Ajax Model
  4.  *
  5.  * PHP version 5
  6.  *
  7.  * @category  CodeIgniter
  8.  * @package   EVD CMS
  9.  * @author    Frederico Carvalho
  10.  * @copyright 2008 Mentes 100Limites
  11.  * @version   0.1
  12. */
  13.  
  14. class Ajax_model extends Model
  15. {
  16.     /**
  17.     * Instanciar o CI
  18.     */
  19.     public function Ajax_model()
  20.     {
  21.         parent::Model();
  22.         $this->CI =& get_instance();
  23.     }
  24.    
  25.     public function get_select_countries()
  26.     {
  27.         //Select table name
  28.         $table_name = "country";
  29.        
  30.         //Build contents query
  31.         $separator = (string) ',';
  32.         //$this->db->select('concat(iso3, concat('. addcslashes($separator) .', iso3))')->from($table_name);
  33.        
  34.         $query = $this->db->query("select concat(iso3, concat(':', iso3)) as name from country where iso3 is not null");
  35.         //Get contents
  36.         return $query->result_array();
  37.     }
  38.    
  39.     public function get_countries()
  40.     {
  41.         //Select table name
  42.         $table_name = "country";
  43.        
  44.         //Build contents query
  45.         $this->db->select('id,iso,name,printable_name,iso3,numcode')->from($table_name);
  46.         $this->CI->flexigrid->build_query();
  47.        
  48.         //Get contents
  49.         $return['records'] = $this->db->get();
  50.         //echo $this->db->last_query();
  51.         //Build count query
  52.         $this->db->select('count(id) as record_count')->from($table_name);
  53.         $this->CI->flexigrid->build_query(FALSE);
  54.         $record_count = $this->db->get();
  55.         $row = $record_count->row();
  56.        
  57.         //Get Record Count
  58.         $return['record_count'] = $row->record_count;
  59.    
  60.         //Return all
  61.         return $return;
  62.     }
  63.    
  64.     /**
  65.     * Remove country
  66.     * @param int country id
  67.     * @return boolean
  68.     */
  69.     public function delete_country($country_id)
  70.     {
  71.         $delete_country = $this->db->query('DELETE FROM country WHERE id='.$country_id);
  72.        
  73.         return TRUE;
  74.     }
  75. }
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement