Пример #1
0
    /**
     * @param string $functionSignature
     * @return int
     */
    public function countFunctionSignature($functionSignature)
    {
        $split = explode(':', $functionSignature);
        return $this->adapter->fetchOne('SELECT COUNT(DISTINCT tweet)
			FROM tweetist
			WHERE dataset = :dataset
			AND function = :function AND signature = :signature', array('dataset' => $this->dataset, 'function' => $split[0], 'signature' => $split[1]));
    }
Пример #2
0
 /**
  * Write a message to the log.
  *
  * @param  array  $event  event data
  * @return void
  * @throws Zend_Log_Exception
  */
 protected function _write($event)
 {
     $config = Zend_Registry::get('config');
     $isLogMsg = (bool) $config['logging']['log']['enable'];
     $isLogStat = (bool) $config['logging']['statistics']['enable'];
     $isLogEx = (bool) $config['logging']['exeption']['enable'];
     // Проверим возможность логирования
     if ($this->_table == 'log_msg' && !$isLogMsg) {
         return;
     } elseif ($this->_table == 'log_stat' && !$isLogStat) {
         return;
     } elseif ($this->_table == 'log_error' && !$isLogEx) {
         return;
     }
     // Удалим лишние записи
     if ($this->_max_rows && $this->_max_rows !== -1) {
         $select = $this->_db->select();
         $select->from($this->_table, 'count(*)');
         $count_rows = (int) $this->_db->fetchOne($select);
         if ($count_rows >= $this->_max_rows) {
             // Получим массив ids для удаления строк в таблице
             $limit = $count_rows - $this->_max_rows;
             $limit++;
             $select = $this->_db->select();
             $select->from($this->_table, 'id');
             $select->limit($limit, 0);
             $row_ids = $this->_db->fetchCol($select);
             // Удалим строки из таблицы
             foreach ($row_ids as $id) {
                 $this->_db->delete($this->_table, 'id=' . $id);
             }
         }
     }
     // Запишем событие в лог
     parent::_write($event);
 }