CodeIgniter Forums
$q->where('hotfix.os=hotfixdata.os',null); - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: $q->where('hotfix.os=hotfixdata.os',null); (/showthread.php?tid=54414)



$q->where('hotfix.os=hotfixdata.os',null); - El Forum - 09-07-2012

[eluser]Unknown[/eluser]
Hello everyone i'm attempting to replicate a working SQL statement i've verified it is working due to running the SQL statement from SQLYog (I'm unable to post the code due to limitations on the board?)

The aspect that is causing the problem is this:
$q->where('hotfix.os=hotfixdata.os',null);
both hotfix and hotfixdata have been joined with $q->join(...);
if this line is remove all works but more data is return than should be, however i have to JOIN on hotfix.hotfixid=hotfixdata.hotfixid

I've also tried using $q->query which again returns another error.


$q->where('hotfix.os=hotfixdata.os',null); - El Forum - 09-07-2012

[eluser]Aken[/eluser]
Post the query, and use $this->db->last_query() to see what the active record query being generated is. Compare those with your original and find the problem.


$q->where('hotfix.os=hotfixdata.os',null); - El Forum - 09-10-2012

[eluser]Unknown[/eluser]
EDIT: Resolved:
I had been using the wrong syntax from within Code Igniter Example for future and references:
$q = $this->load->database('database', TRUE);
$dev=$q->query("SQL QUERY IN HERE");
return $dev->result();

UNEDIT

[quote author="Aken" date="1347056624"]Post the query, and use $this->db->last_query() to see what the active record query being generated is. Compare those with your original and find the problem.[/quote]
Code:
$dev=$q->query("SQL QUERY IN HERE");
        echo var_dump($dev);
        echo"<hr />";
        echo $q->last_query();
var_dump() returns:object(CI_DB_mysqli_result)#27 (7) { ["conn_id"]=> object(mysqli)#26 (17) { ["affected_rows"]=> int(51) ["client_info"]=> string(50) "mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $" ["client_version"]=> int(50008) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["field_count"]=> int(5) ["host_info"]=> string(26) "192.168.100.246 via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(16) "5.1.57-community" ["server_version"]=> int(50157) ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(124707002) ["warning_count"]=> int(0) } ["result_id"]=> object(mysqli_result)#25 (5) { ["current_field"]=> int(0) ["field_count"]=> int(5) ["lengths"]=> NULL ["num_rows"]=> int(51) ["type"]=> int(0) } ["result_array"]=> array(0) { } ["result_object"]=> array(0) { } ["current_row"]=> int(0) ["num_rows"]=> int(51) ["row_data"]=> NULL }

last query returns: the full query even with the table