Beispiel #1
0
 public function showRows()
 {
     // Connect to database
     $db = Db::getInstance();
     if (!$db->connect($this->_registry->config->dbserver, $this->_registry->config->dbuser, $this->_registry->config->dbpass, $this->_registry->config->dbname, true)) {
         $db->print_last_error(false);
         $db->printMe();
     }
     if (isset($this->_registry->request->args[0])) {
         $tables = array();
         $db = Db::getInstance();
         $tableName = $this->_registry->request->args[0];
         $where = isset($this->_registry->request->request['where']) ? " where " . $this->_registry->request->request['where'] : '';
         $tables[$tableName] = array('fields' => array(), 'rows' => 0);
         $bResults = $db->select("select * from  {$tableName} {$where} limit 200");
         while ($bRow = $db->get_row($bResults, 'MYSQL_ASSOC')) {
             $tables[$tableName]['fields'][] = $bRow;
         }
         $cResults = $db->select_one("select count(*) num from {$tableName}");
         $tables[$tableName]['rows'] = $cResults;
     }
     $this->_registry->title = 'Database Structure';
     $this->_registry->tables = $tables;
     $this->viewHTML('tables.php');
 }
    error_reporting(E_ALL);
} else {
    // Production
    define('APPLICATION_ENVIRONMENT', 'PRODUCTION');
    error_reporting(E_STRICT);
}
// load configuration file
$config = \library\Config::getConfigArray($basePath . 'application/default/config/config.ini', APPLICATION_ENVIRONMENT);
$logDir = $config['logDir'];
if (!is_dir($logDir)) {
    mkdir($logDir);
}
$log = isset($log) && !empty($log) ? $log : $logDir . '/eventCrunch.' . date('Ymd', strtotime('now')) . '.log';
$awsAccessKey = $config['awsAccessKey'];
$awsSecretAccessKey = $config['awsSecretAccessKey'];
$kissmetricsBucket = $config['kissmetricsBucket'];
// ready to run
echo "using log: {$log}";
\library\traits\Loging::setLog($log);
\library\traits\Loging::printTime("Status: starting up eventsCrunch.php " . date('Y-m-d H:i:s', strtotime('now')));
// The gear - load database and run
$db = \library\Db::getInstance($config['dbserver'], $config['dbname']);
if (!$db->connect($config['dbserver'], $config['dbuser'], $config['dbpass'], $config['dbname'], true)) {
    \library\traits\Loging::printTime("Error connecting with database : " . $db->last_error);
    exit(1);
}
$eventCrunch = Cron_EventCrunch::getInstance();
$eventCrunch->crunchEvents();
// All methods
\library\traits\Loging::printTime("Status: finish eventsCrunch.php " . date('Y-m-d H:i:s', strtotime('now')));
exit(0);