Welcome Guest, Not a member yet? Register   Sign In
using database library calls within a helper
#4

[eluser]jegbagus[/eluser]
[quote author="AF" date="1251710269"]Could you give me a little more detail? Here is the code:

function datediff($sdate, $anchor) {
$query="SELECT DATEDIFF('$sdate','$anchor')";
$query =$this->db->query($query);
$row=$query->result_array();


return($row);
}

So, maybe this is a basic question, but what is the & in your case?

And, thank you too.[/quote]

hello af, & get_instance suppose to get instance that CI create when you fire a request. your library and everything that you call from load function will be at this instance. the code will be
Code:
function datediff($sdate, $anchor) {
    $CI =& get_instance();
    $query="SELECT DATEDIFF('$sdate','$anchor')";
    $query =$CI->db->query($query);
    $row=$query->result_array();
    
    return($row);
}
but honestly, i think you should place this code at your library.
any other opinion?


Messages In This Thread
using database library calls within a helper - by El Forum - 08-30-2009, 07:19 PM
using database library calls within a helper - by El Forum - 08-30-2009, 09:34 PM
using database library calls within a helper - by El Forum - 08-30-2009, 10:17 PM
using database library calls within a helper - by El Forum - 08-30-2009, 10:45 PM
using database library calls within a helper - by El Forum - 08-31-2009, 02:18 AM
using database library calls within a helper - by El Forum - 08-31-2009, 07:23 AM
using database library calls within a helper - by El Forum - 08-31-2009, 09:13 AM



Theme © iAndrew 2016 - Forum software by © MyBB