public static function save()
 {
     $insert['url'] = $_GET['r'];
     $insert['route'] = REST::getRouteName();
     $insert['params'] = json_encode(REST::getInputs());
     $insert['ip'] = $_SERVER['REMOTE_ADDR'];
     PG::insert('logs', $insert);
 }
 public static function lasts($start = 0, $active = true)
 {
     $where = 'TRUE';
     if ($active !== null) {
         $where = "estacao_post.active = " . ($active ? '1' : '0');
     }
     $posts = PG::toMatrix("SELECT\n\t\t\t\testacao_post.*,\n\t\t\t\tusers.name gamer_name,\n\t\t\t\tusers.src gamer_image,\n\t\t\t\tusers.slug gamer_slug\n\t\t\tFROM estacao_post\n\t\t\tLEFT JOIN users\n\t\t\tON users.id = estacao_post.user_id\n\t\t\tWHERE {$where}\n\t\t\tORDER BY estacao_post.created_at DESC\n\t\t\tLIMIT 12\n\t\t\tOFFSET {$start}");
     return $posts;
 }
 public static function all($active = null)
 {
     $table = self::$static_table;
     $where = 'TRUE';
     if ($active !== null) {
         $where = "{$table}.active = " . ($active ? 'TRUE' : 'FALSE');
     }
     return PG::toMatrix("SELECT * FROM {$table} WHERE {$where} ORDER BY id ASC");
     // ORDER BY weight ASC
 }
 public static function lasts($start = 0, $active = true)
 {
     $table = self::$static_table;
     $where = 'TRUE';
     if ($active !== null) {
         $where = "{$table}.active = " . ($active ? '1' : '0');
     }
     $users = PG::toMatrix("SELECT\n\t\t\t\t{$table}.*\n\t\t\tFROM {$table}\n\t\t\tLEFT JOIN users\n\t\t\tON users.id = estacao_post.user_id\n\t\t\tWHERE {$where}\n\t\t\tORDER BY estacao_post.created_at DESC\n\t\t\tOFFSET {$start}");
     return $users;
 }
示例#5
0
 public static function deleteFrom($table, $where)
 {
     self::connect();
     $query = "DELETE FROM {$table} WHERE {$where}";
     self::$result = pg_query($query) or die('Delete failed: ' . pg_last_error());
     $affected = pg_affected_rows(self::$result);
     self::disconnect();
     return $affected;
 }