Welcome Guest, Not a member yet? Register   Sign In
Weird error
#1

[eluser]alexbet[/eluser]
Hi All,

This is driving me nuts, and any help is appreciated. Here is my code:

Code:
$sql = "SELECT SUM(cf_revshareCommissions.commission) AS commission
      FROM cf_revshareCommissions, tblMerchants
      WHERE cf_revshareCommissions.merchantid=tblMerchants.merchantid
      AND cf_revshareCommissions.userid=".$userid."
      AND cf_revshareCommissions.eventdate >= ".$start_date."
      AND cf_revshareCommissions.eventdate <= ".$end_date."
      AND cf_revshareCommissions.locked='0'
      AND cf_revshareCommissions.bad=0
      AND cf_revshareCommissions.merchantid=".$merchantid."
      GROUP BY cf_revshareCommissions.merchantid
      LIMIT 1
      ";

    $query = $this->db->query($sql);
    
    if ($query->num_rows() > 0)
    {
     $row = $this->$query->row();
     $commission = $row->commission;
    }

I am getting a result of 1.32 when I run that query on the MySql server directly.

With Codeigniter though, I am getting this error:

Message: Object of class CI_DB_mysql_result could not be converted to string

And the line that I am getting the error on is this one:

$row = $this->$query->row();

What could I be doing wrong? I really have no idea why I am getting this error as I have 3 more queries like this with different parameters that don't give me an error.
#2

[eluser]alexbet[/eluser]
Just in case someone needs to know, the "cf_revshareCommissions.commission" table column is of the type "float".

Thanks!
#3

[eluser]CodeIgniteMe[/eluser]
I believe you are in excess of codes
Code:
$row = $this->$query->row();
should only be
Code:
$row = $query->row();
#4

[eluser]alexbet[/eluser]
Ahhh, that's what you get when you work when you are tired. Thanks a lot LA. Smile
#5

[eluser]CodeIgniteMe[/eluser]
No problem, just don't forget to get some rest once in a while.




Theme © iAndrew 2016 - Forum software by © MyBB