Esempio n. 1
0
 /**
  * Returns a singleton instance of the Zend_Db_Table object for this table.
  * 
  * @param string $table
  * @return Zend_Db_Table
  */
 public static function getInstance($table)
 {
     if (!isset(self::$_instances[$table])) {
         self::$_instances[$table] = new Zend_Db_Table(array('name' => $table, 'db' => Yadda_Db::getInstance()));
     }
     return self::$_instances[$table];
 }
Esempio n. 2
0
 public static function pull($from, $to)
 {
     $db = Yadda_Db::getInstance();
     $days = array();
     $cur = $from;
     while ($cur <= $to) {
         $days[$cur] = array();
         // get the number of deals for this day
         $select = $db->select()->from('deal', array('cnt' => 'COUNT(1)'))->where('DATE_FORMAT(created, \'%Y-%m-%d\') = ?', $cur);
         $row = $db->fetchRow($select);
         $days[$cur]['deals'] = (int) $row['cnt'];
         // get the number of votes for the day
         $select = $db->select()->from('vote', array('cnt' => 'COUNT(1)'))->where('DATE_FORMAT(FROM_UNIXTIME(created), \'%Y-%m-%d\') = ?', $cur);
         $row = $db->fetchRow($select);
         $days[$cur]['votes'] = (int) $row['cnt'];
         // get the number of subscriptions for the day
         $select = $db->select()->from('subscription', array('cnt' => 'COUNT(1)'))->where('DATE_FORMAT(created, \'%Y-%m-%d\') = ?', $cur);
         $row = $db->fetchRow($select);
         $days[$cur]['subscriptions'] = (int) $row['cnt'];
         $cur = date('Y-m-d', strtotime('+1 day', strtotime($cur)));
     }
     return $days;
 }
Esempio n. 3
0
 /**
  * Adds a deal to the featured deals roll.
  * 
  * @param int $id
  * @return void
  */
 public static function feature($id)
 {
     $deal = self::find($id);
     $db = Yadda_Db::getInstance();
     $db->insert('feature', array('deal_id' => $deal['id'], 'created' => time()));
 }