<?php

class Model_DbTable_Fixture extends Zend_Db_Table
{
    protected $_name = 'Fixture';
    
   public function insertData($data)
    {
       
       try{
      
           $id = $this->insert($data);
           return $id;
       }catch(Exception $e){
       	echo "<pre>";
       	print_r($e);
          return  false;
       }
       
    }
    
     public function getFixturesThisWeek()
    {
    	$Mon = date("Y-m-d", strtotime('monday this week'));   

$Sun = date("Y-m-d", strtotime('sunday this week'));
       $select = $this->select();
       $select->from(array('F' => "Dashboard_Fixtures_view"));
       //$select->where("F.TID ='162' ");
       $select->order("FixtureDate ASC");
        $select->setIntegrityCheck(false);
        $fixtures =  $this->fetchAll($select);
        $fixtures_list = array();
        if(count($fixtures)>0){
            $fixtures = $fixtures->toArray();
            foreach($fixtures as $fixture){
            $fixtures_list[$fixture["FixtureDate"]]["FixtureDate"]=$fixture["FixtureDate"];
            $fixtures_list[$fixture["FixtureDate"]]["FIX"][$fixture["FID"]]=$fixture;
            }
        }
        return $fixtures_list;
    }
	
	public function getAllFixtureIDs()
    {
    	$select = $this->select();
       $select->from(array('F' => $this->_name),array("FID","FixtureDate"))->order("FixtureDate ASC");
     
       $select->order("FixtureDate ASC");
        $select->setIntegrityCheck(false);
        $fixtures =  $this->fetchAll($select);
        
        return $fixtures;
    }
	 
	
}