• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI model queries coming up empty

#1
[eluser]wp4nuv[/eluser]
Hello all,

I'm in the process of deploying a CI app and even though during production all queries executed successfully, upon deployment query execution is spotty: only 2 queries successfully complete. DB connection is through OCI8 to Oracle 10g and has been verified to be running normally. One would think that if there was a problem with the DB connection, no queries would execute. Has anyone seen this behaviour?

They fail with this error:
Quote:Fatal error: Call to a member function row() on a non-object in /var/www/daily_cash/system/application/views/main_view.php on line 51

This are lines 51 through 55 of that view:
Quote:
<?$row1 = $query1->row();?>
<?$row2 = $query2->row();?>
<?$row3 = $query3->row();?>
<?$row4 = $query4->row();?>
<?$row = $query->row();?>

Here's an example of one of my controller functions and some of it's corresponding models (the remaining queries are very similar):

BTW, session data has been verified as well; it's writing correctly, so where there is mention of session data, it's all there correctly.

Code:
function main()
        {
            $this->load->model('consultas');
            $data['title']="Main Menu";
            $data['heading']="Main Menu";
            $data['fecha'] = $this->session->userdata('date');
            
           if ($this->session->userdata('priv2')== 'BYUSER'){
                $data['query1'] = $this->consultas->directors_some($data['fecha'],$this->session->userdata('id'));
                $data['query2'] = $this->consultas->supervisors_some($data['fecha'],$this->session->userdata('id'));
                $data['query3'] = $this->consultas->store_some($data['fecha'],$this->session->userdata('id'));
                $data['query4'] = $this->consultas->store_some_sum($data['fecha'],$this->session->userdata('id'));
                $data['query'] = $this->consultas->max_length();
            }
            else {
                $data['query1'] = $this->consultas->directors_all($data['fecha'],$this->session->userdata('id'));
                $data['query2'] = $this->consultas->supervisors_all($data['fecha'],$this->session->userdata('id'));
                $data['query3'] = $this->consultas->store_all($data['fecha'],$this->session->userdata('id'));
                $data['query4'] = $this->consultas->store_all_sum($data['fecha'],$this->session->userdata('id'));
                $data['query'] = $this->consultas->max_length();
            }

            $this->load->view('main_view',$data);
//      

        }
Code:
function directors_all($fecha){
//-- Query para agregar todos los Directores
//-- La instruccion ADD se llena, para cada tupla entregada por el query como:
//--               ADD( DIRECTOR_ID, 0, "DIRECTOR_NAME")
$query = $this->db->query("SELECT emp_fullname director_name, director_id
            FROM DIM_EMP,
                (     SELECT DISTINCT director_id
             FROM v_aux_summ_sales
             WHERE     dob =  '".$fecha."'

                )
            WHERE emp_id = director_id;");
        return $query;
    }
   function directors_some($fecha,$usuario){
//-- Query para agregar todos los Directores
//-- La instruccion ADD se llena, para cada tupla entregada por el query como:
//--               ADD( DIRECTOR_ID, 0, "DIRECTOR_NAME")
$query = $this->db->query("SELECT emp_fullname director_name, director_id
            FROM DIM_EMP,
                (     SELECT DISTINCT director_id
             FROM v_aux_summ_sales
             WHERE     dob =  '".$fecha."'
                         AND    store_id IN (SELECT store_id FROM v_aux_store_rigths WHERE emp_with_rigth = ".$usuario.")
                )
            WHERE emp_id = director_id;");
       return $query;
    }
Any suggestions will be greatly appreciated!

Pedro Maldonado

#2
[eluser]n0xie[/eluser]
Have you tried returning the result object instead of the whole db object?

It's a long shot but it might be worth a try.
Change
Code:
return $query;
To
Code:
return $query->row();

Change
Code:
<?$row1 = $query1->row();?>
To
Code:
<?php $row1 = $query1; ?>
...

#3
[eluser]wp4nuv[/eluser]
I did try your suggestion, yet the result is the same. It's as if the connection wasn't being made to begin with. Curious thing is that I can connect with any client w/o problems and do the same queries, so the tnsnames.ora file is correct.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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