• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$query->result() equivalent for a resource

#1
[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!

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

#3
[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?

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

Or that...

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

Exactly what I was after, thanks.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.