Welcome Guest, Not a member yet? Register   Sign In
Active Queries problem
#5

(This post was last modified: 07-15-2015, 01:37 AM by codebigneer.)

Same problem appears again

Here what I am doing

model.php


Code:
function a()
{
$record['comparitive_dividend'] = $this->get_comparative_dividends($trail_balance_year);
return $record;
}

public function get_comparative_dividends($year = null)
{
$user = $this->session->userdata('user');
$this->db->select('amount');
$where = array(
'clientId' => $user['UserID'],
'category_id' => 174,
'year' => $year
);
$record = array();
$query = $this->db->get_where('cashman_trial_balance',$where);
echo $this->db->last_query();
if($query->num_rows() > 0)
{
$result = $query->result();
$record['current_year'] = $result[0]->amount;
}else{
$record['current_year'] = 0;
}

$year = explode('/',$year);
$year[0] = ($year[0]-1);
$year[1] = ($year[1]-1);
$year = implode('/',$year);
$this->db->select('amount');
$where = array(
'clientId' => $user['UserID'],
'category_id' => 174,
'year' => $year
);

$query = $this->db->get_where('cashman_trial_balance',$where);
if($query->num_rows() > 0)
{
$result = $query->result();
$record['previous_year'] = $result[0]->amount;
}else{
$record['previous_year'] = 0;
}
return $record;
}


The above code ouputs
Code:
SELECT *, * FROM (`cashman_trial_balance`) WHERE `clientId` = '145' AND `category_id` = 174 AND `year` = '2014/2015'

The two stars causes the query to break.
Reply


Messages In This Thread
Active Queries problem - by codebigneer - 07-08-2015, 02:32 AM
RE: Active Queries problem - by gadelat - 07-08-2015, 07:38 AM
RE: Active Queries problem - by codebigneer - 07-08-2015, 09:36 PM
RE: Active Queries problem - by mwhitney - 07-09-2015, 10:01 AM
RE: Active Queries problem - by codebigneer - 07-15-2015, 12:15 AM
RE: Active Queries problem - by mwhitney - 07-15-2015, 07:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB