• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to create funciton or class or???

ive been using lots of query to do this


the only thing changing is the date. can i create a function and just send the date to the function/class and insert in my index function .. how do it do it.?

[EDIT] removed a superfluous or_where

Say you do you query in the index() method of your controller. Then you would get this.
function index() {
    // Set up the dates to query
    $dates = array("2008-11-22", "2008-12-06", "2008-11-30", "2008-11-29", "2008-11-23");
    // Get results
    $data = $this->_date_query($dates)

function _date_query($dates) {
    // Query database
    foreach($dates as $date) {
        // Set a where statement for each date
        $this->db->or_where('date', $date);
    $query = $this->db->get('sale',$sql7);
    // Return results
    if($query->num_rows() > 0){
        return $query->result_array();
    else {
        return false;

You had best move the _date_query($dates) function to a model, bacause it handels db actions. (remove the underscore from the function name, in that case.)

ok thx.. im trying it.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

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