Example #1
0
 /**
  * Will log an exception
  *
  * @param Exception $e            
  */
 public static function e($e)
 {
     $message = $e->getMessage();
     $code = $e->getCode();
     $file = $e->getFile();
     Logger::error('Exception ' . $code . ' ' . $message . ' ' . $file);
 }
Example #2
0
 /**
  */
 protected function createTable()
 {
     $endpoint = $this->request->endpoint;
     $keyspace = $this->request->keyspace;
     $this->cassandra->createKeyspace($keyspace);
     $createTableQuery = $this->getCreateTableQuery();
     $this->cassandra = new Connector(Config::getConfig('CassandraNodeString'), (int) Config::getConfig('CassandraPort'));
     $this->cassandra->connect($keyspace);
     Logger::debug('Create Table Query : ' . $createTableQuery);
     $this->cassandra->query($createTableQuery);
 }
Example #3
0
 /**
  * Will insert a record in the database with an accurate updated / created timestamp
  *
  * @param Request $request            
  * @return Cassandra\Rows
  */
 public function insert(Request $request)
 {
     $body = $request->body;
     $values = '';
     $columns = '';
     if (!isset($body['s_id'])) {
         // New request
         $body['create_time'] = $request->startTime;
         $body['s_id'] = $request->id;
     }
     $body['update_time'] = $request->startTime;
     foreach ($body as $column => $value) {
         //
         $columns .= $column . ', ';
         $values .= "'" . $value . "', ";
     }
     $columns = substr($columns, 0, -2);
     $values = substr($values, 0, -2);
     $query = "INSERT INTO {$request->keyspace}.{$request->table} ({$columns}) VALUES ({$values});";
     Logger::info('Insert Query : ' . $query);
     $results = $this->query($query);
     return $results;
 }