Welcome Guest, Not a member yet? Register   Sign In
about upgrading CI version
#1

[eluser]kikz4life[/eluser]
hi,. i am optimizing a website in CI that has the version of 1.6.3 and thinking of upgrading the CI version to 1.7.2. Following the process in Upgrading CI version i encounter a problem. A Database Error occurred. I am able to access/login the website but when i click the other links in my main page this thing happen. I trace the problem when i copy-paste the system/database folder 1.7.2 to my website.

Is it just ok if i don't include the database folder in CI ver 1.7.2 to my website. Without including it, the website works fine. need some suggestion in this.

could anyone help me with this?
attach here is a picture of the said error.


thanks
-Dean
#2

[eluser]pistolPete[/eluser]
Can you post the php code which generates that query in your model / controller?
#3

[eluser]kikz4life[/eluser]
Controller

Code:
class Main extends Controller {

    function Main()
    {
        parent::Controller();
        $method = $this->uri->rsegment(2);
        $user = $this->session->userdata('user');
        if (!$user) redirect('sec_users/login');
        
        $this->load->model('Dataset_db');
    }
    
    function index()
    {
        $data['navs'] = $this->Dataset_db->buildNav(0);
        $data['current_tab'] = 'dashboard';
        
        $data['content'] = $this->load->view('home',$data,true);
        $this->load->vars($data);
        $this->load->view('default_view');
    }
    
    function close_tab($module,$nogo=false)
    {
        if (!$module) return true;

        $tabs = $this->session->userdata('tabs');
        if (!$tabs) $tabs = array();
        $last_tab = '';
                
        foreach ($tabs as $tab) {
            if ($tab['link']==$module)
                {
                unset($tabs[$module]);
                $this->session->set_userdata('tabs',$tabs);
                if ($nogo) return true;
                redirect($last_tab);
                }
            $last_tab = $tab['link'];
        }
    }
    
    function options()
    {
        $item = $this->input->post('item');        
        $data['prop']="class='tb'";
        $data['name']=$this->input->post('type');
        $data['value']=$this->input->post('value');
        $data['options'] = $this->Dataset_db->getProvince($item);
        $this->load->view("template/options",$data);
    }

    
}

Model

Code:
class Dataset_db extends Model {

    function Dataset_db()
    {
        parent::Model();
    }

    function getTypes($datacode)
    {
        $this->db->select('data_id,data_value,data_display,description');
         $this->db->where("data_code='$datacode' AND display='1'");
        $this->db->orderby("order_idx", "asc");
        $query = $this->db->get('sec_dataset');
        return $query->result();        
    }
    
    function getSearchTypes($datacode)
    {
        $this->db->select('data_id,data_value,data_display,description');
         $this->db->where("data_code='$datacode'");
        $this->db->orderby("order_idx", "asc");
        $query = $this->db->get('sec_dataset');
        return $query->result();        
    }
    
    function getNavs($parent)
    {
        $this->db->select('module_id,module,link,icon');
        $this->db->orderby("sort", "asc");
        $query = $this->db->get_where('sec_modules', array('publish' => '1','parent' => $parent));
        return $query->result_array();        
    }
    
    function buildNav($p)
    {
        $rs = $this->getNavs($p);
        $nav = array();
        foreach ($rs as $row)
            {
                $nav[] = array ('row'=>$row,'child'=>$this->buildNav($row['module_id']));            
            }                
        return $nav;
    }
    
    function getModule($module)
    {
        $this->db->select('module_id,module,link,icon');
        $query = $this->db->get_where('sec_modules', array('publish' => '1','link' => $module));
        return $query->row_array();        
    }
    
    function getAccess($role_id, $module_id, $company_id)
    {
        $query = $this->db->get_where('sec_accesslevel', array('role_id' => $role_id, 'module_id' => $module_id, 'company_id' => $company_id));
        return $query->row_array();    
    }
    
    function getCountries()
    {
        $this->db->select('iso,printable_name');
        $this->db->orderby("printable_name", "asc");
        $query = $this->db->get('maint_country');
        return $query->result();        
    }
    
    function getProvince($c)
    {
        $this->db->select('id,state');
        $this->db->orderby("state", "asc");
        $query = $this->db->get_where('maint_state', array('iso' => $c));
        return $query->result_array();        
    }
    
    function getData()
    {
        $this->db->select('data_id,data_code');
        $this->db->orderby("data_id", "asc");
        $this->db->groupby("data_code");
        $query = $this->db->get('sec_dataset');
        return $query->result();        
    }
    
    function saveLog($data)
    {
        $company = $this->session->userdata('company');
        $data['company_id'] = $company['company_id'];
        
        $user = $this->session->userdata('user');
        $data['user_id'] = $user['user_id'];
        
        $data['log_date'] = date("Y-m-d H:i:s");
        $data['machine_name'] = gethostbyaddr($_SERVER['REMOTE_ADDR']);
        $data['ip_address'] = $_SERVER['REMOTE_ADDR'];  
        
        $this->db->insert('sec_logs', $data);
    }

}

this is the entire codes which trigger all module links of my website.
#4

[eluser]pistolPete[/eluser]
It seems to be a problem with protecting identifiers.

You could either disable that behaviour:
Code:
$this->db->where("data_code='$datacode'", NULL, FALSE);

Or you could try this:

Code:
$this->db->where('data_code', $datacode);
#5

[eluser]kikz4life[/eluser]
hi there pistolPete,

thanks for the code. I tried to substitute your code in the function getSearchTypes($datacode) and it works perfect. Now I can access some of the module. thanks again Pete. Smile

But i have encountered another Database error and now its in the function getTypes($datacode). And tried to fix it using two where clauses since it has 2 condition, it load but no data retrieve from my db.
Code:
$this->db->where('data_code', $datacode);
$this->db->where('display','1');


Could you help me with this again Pete.




Theme © iAndrew 2016 - Forum software by © MyBB