Welcome Guest, Not a member yet? Register   Sign In
Converting from perl to CI PHP
#1

[eluser]Shaileen[/eluser]
"SELECT count(*) from dsl_tt WHERE order_id = '$quote_id' AND resolved = 0";


can anybody help me to write the CI code for the above perl statement..

I tried this one..
function get_tt_exist($order_id)
{
$this->db->count_all('dsl_tt');
$this->db->where('order_id ', $order_id);
$this->db->where('resolved', 0);
$query = $this->db->get();
$row = $query->row();
return $row->order_id;
}


I am getting the following error :
ERROR: SELECT * with no tables specified is not valid

SELECT * WHERE "order_id" = 'tq390360400062' AND "resolved" = 0

Can you please help me with this..
#2

[eluser]djenniex[/eluser]
I think your looking for something like this:

Code:
$this->db->where(‘order_id ‘, $order_id);
$this->db->where(‘resolved’, 0);
$query = $this->db->get('dsl_tt');

if ($query->num_rows() > 0)
{
    return TRUE;
}

return FALSE;

This will test if the order_id exists in the table.

Now, if you wanted to return the number of rows in the table with the order_id, then you would use:

Code:
$query = $this->db->count_all_results('dsl_tt')

and then return

Code:
return $query->num_rows()
#3

[eluser]Shaileen[/eluser]
great...works now!!

thanks!!




Theme © iAndrew 2016 - Forum software by © MyBB