CodeIgniter Forums
$query->result() equivalent for a resource - 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: $query->result() equivalent for a resource (/showthread.php?tid=7942)



$query->result() equivalent for a resource - El Forum - 04-28-2008

[eluser]Unknown[/eluser]
Hi, I'm new to CI and am using it in combination with AMFPHP, the flash-remoting gateway.

My problem is that AMFPHP expects a resource returned from a DB query (the kind you get from using mysql_query);

Code:
function getAllPoints()
    {
        mysql_connect(DB_HOST, DB_USER, DB_PASS);
        mysql_select_db(DB_NAME);
        return mysql_query(sprintf("SELECT * FROM points"));
    }

but I'd rather use CI's nicer DB methods;

Code:
function getAllPoints()
    {
               $query = $this->db->get($this->table);
        return $query->result();
    }


Is there any way to get $query->result() to return a resource like mysql_query does?

Thanks!


$query->result() equivalent for a resource - El Forum - 04-28-2008

[eluser]m4rw3r[/eluser]
The $query->result_id contains the resource.


$query->result() equivalent for a resource - El Forum - 04-28-2008

[eluser]TheFuzzy0ne[/eluser]
Assuming you're using MySQL, I think you'd just need to extend the existing CI_DB_mysql_result class, but I think you'd need to use your custom object, rather than CI's $this->db.

Unless there's another way, you can just put it into a library, and maybe call it my_db, or db2?


$query->result() equivalent for a resource - El Forum - 04-28-2008

[eluser]TheFuzzy0ne[/eluser]
[quote author="m4rw3r" date="1209427743"]The $query->result_id contains the resource.[/quote]

Or that...


$query->result() equivalent for a resource - El Forum - 04-29-2008

[eluser]Unknown[/eluser]
[quote author="m4rw3r" date="1209427743"]The $query->result_id contains the resource.[/quote]

Exactly what I was after, thanks.