Mage_Log_Model_Mysql4_Aggregation Class Reference

Inheritance diagram for Mage_Log_Model_Mysql4_Aggregation:

Mage_Core_Model_Mysql4_Abstract Mage_Core_Model_Resource_Abstract

List of all members.

Public Member Functions

 _construct ()
 getLastRecordDate ()
 getCounts ($from, $to, $store)
 saveLog ($data, $id=null)
 removeEmpty ($date)
 getLogId ($from, $to)


Detailed Description

Definition at line 27 of file Aggregation.php.


Member Function Documentation

_construct (  ) 

Resource initialization

Reimplemented from Mage_Core_Model_Resource_Abstract.

Definition at line 29 of file Aggregation.php.

00030     {
00031         $this->_init('log/summary_table', 'log_summary_id');
00032     }

getCounts ( from,
to,
store 
)

Definition at line 42 of file Aggregation.php.

00043     {
00044         $result = array('customers'=>0, 'visitors'=>0);
00045         $select = $this->_getReadAdapter()->select()
00046             ->from($this->getTable('customer'), 'visitor_id')
00047             ->where('login_at >= ?', $from)
00048             ->where('login_at <= ?', $to);
00049         if ($store) {
00050             $select->where('store_id = ?', $store);
00051         }
00052 
00053         $customers = $this->_getReadAdapter()->fetchCol($select);
00054         $result['customers'] = count($customers);
00055 
00056 
00057         $select = $this->_getReadAdapter()->select();
00058         $select->from($this->getTable('visitor'), 'COUNT(*)')
00059             ->where('first_visit_at >= ?', $from)
00060             ->where('first_visit_at <= ?', $to);
00061 
00062         if ($store) {
00063             $select->where('store_id = ?', $store);
00064         }
00065         if ($result['customers']) {
00066             $select->where('visitor_id NOT IN(?)', $customers);
00067         }
00068 
00069         $result['visitors'] = $this->_getReadAdapter()->fetchOne($select);
00070 
00071 
00072         return $result;
00073     }

getLastRecordDate (  ) 

Definition at line 34 of file Aggregation.php.

00035     {
00036         $select = $this->_getReadAdapter()->select()
00037             ->from($this->getTable('summary_table'), array('date'=>'MAX(add_date)'));
00038 
00039         return $this->_getReadAdapter()->fetchOne($select);
00040     }

getLogId ( from,
to 
)

Definition at line 91 of file Aggregation.php.

00092     {
00093         $select = $this->_getReadAdapter()->select()
00094             ->from($this->getTable('summary_table'), 'summary_id')
00095             ->where('add_date >= ?', $from)
00096             ->where('add_date <= ?', $to);
00097 
00098         return $this->_getReadAdapter()->fetchOne($select);
00099     }

removeEmpty ( date  ) 

Definition at line 85 of file Aggregation.php.

00086     {
00087         $condition = $this->_getWriteAdapter()->quoteInto('add_date < ? AND customer_count = 0 AND visitor_count = 0', $date);
00088         $this->_getWriteAdapter()->delete($this->getTable('summary_table'), $condition);
00089     }

saveLog ( data,
id = null 
)

Definition at line 75 of file Aggregation.php.

00076     {
00077         if (is_null($id)) {
00078             $this->_getWriteAdapter()->insert($this->getTable('summary_table'), $data);
00079         } else {
00080             $condition = $this->_getWriteAdapter()->quoteInto('summary_id = ?', $id);
00081             $this->_getWriteAdapter()->update($this->getTable('summary_table'), $data, $condition);
00082         }
00083     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:28 2009 for Magento by  doxygen 1.5.8