• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't access database table

#1
[eluser]mwaidmann[/eluser]
hi there,

i'm pretty new to codeigniter and i'm playing around with some ideas. now i'm getting a problem while catching data from a database.

my controller function calls different functions in my model to get data from different tables. but only one table answers correct. the second table never returns anything. if i use a different controller and model to access data from this table it works fine.

thanks for any help or suggestions!
maik

#2
[eluser]InsiteFX[/eluser]
If you want help you have to show your code!

InsiteFX

#3
[eluser]mwaidmann[/eluser]
Model:
Code:
class leuchttisch_model extends CI_Model {
    

    function list_leuchttische()
    {
        
        $query = $this->db->get('TABLE1');
        
        if($query->num_rows == 1){
            $temp = $query->result();
            return $temp;
        }
    }
    
    function list_clients()
    {
        
        $query = $this->db->get('TABLE2');
                
        if($query->num_rows == 1){
            $temp = $query->result();
            return $temp;
        }
    }
        
}

Controller:
Code:
<?php

class Leuchttisch extends CI_Controller{
    
    function __construct()
    {
        parent::__construct();
        $this->is_logged_in();
    }
    
    function uebersicht()
    {
    
        $this->load->model('leuchttisch_model');
        
        // leuchttische
        $leuchttische = $this->leuchttisch_model->list_leuchttische();
        $clients =  $this->leuchttisch_model->list_clients();
        
        $data['clients'] = $clients;        
        $data['leuchttische'] = $leuchttische;
        
        $data['main_content'] = 'uebersicht';
        $this->load->view('includes/template',$data);
        
    }

    
    function is_logged_in()
    {
        
        $is_logged_in = $this->session->userdata('is_logged_in');
        
        if(!isset($is_logged_in) || $is_logged_in != TRUE)
        {
            echo 'Kein Zugang!';
            die();
        }
        
    }    
    

}

TABLE2 is the one i can't access.

#4
[eluser]InsiteFX[/eluser]
Code:
if($query->num_rows == 1){
}
// should be
if($query->num_rows() > 0){
}

Controller:
Code:
// leuchttische
$leuchttische = $this->leuchttisch_model->list_leuchttische();
$clients =  $this->leuchttisch_model->list_clients();
        
$data['clients'] = $clients;        
$data['leuchttische'] = $leuchttische;

// Should be like this!

// leuchttische
$data['leuchttische'] = $this->leuchttisch_model->list_leuchttische();
$data['clients']      = $this->leuchttisch_model->list_clients();

There is no reason why you should not be able to retrive both tables! But both tables have to be in the same database!

Are both your tables named TABLE1 and TABLE2 ?

InsiteFX

#5
[eluser]mwaidmann[/eluser]
Thx for your help Smile

#6
[eluser]Unknown[/eluser]
Hi,
Good! So a SQL table linked into an Access database. I think that the issue will be on ... I can't see why they would eliminate that from the 2008 version.

_______
Daniel

Learn English Online

#7
[eluser]InsiteFX[/eluser]
And what does that have to do with this post?

InsiteFX

#8
[eluser]cideveloper[/eluser]
Spam for the link in signature


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.