Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class hb {
- private $pdo;
- public function __construct() {
- ob_start();
- try {
- $this->pdo = new PDO('mysql:host=localhost;dbname=crawler', 'root', 'PASSWORD');
- } catch(PDOException $e) {
- echo 'ERROR: ' . $e->getMessage();
- }
- }
- private function sql($sql, $a = '') {
- $zooi = $this->pdo->prepare($sql);
- $e = $zooi->execute();
- switch($a) {
- case "fetch":
- return (object) $zooi->fetch(PDO::FETCH_ASSOC);
- case "fetchAll":
- return (object) $zooi->fetchAll(PDO::FETCH_ASSOC);
- case "count":
- return $zooi->rowCount();
- case "bool":
- return $e;
- case "id":
- return $this->pdo->lastInsertId();
- case "":
- return $zooi;
- }
- }
- public function latest_game() {
- return (array) $this->sql("SELECT * FROM apps WHERE id IN (SELECT MAX(id) FROM apps)", 'fetch');
- }
- public function preg_file($regex, $url, $filter = PREG_SET_ORDER) {
- $f = str_replace("?", "", utf8_decode(file_get_contents($url)));
- preg_match_all($regex, $f, $m, $filter);
- return $m;
- }
- public function add_to_db($a) {
- if(!is_array($a) || empty($a)) {
- return false;
- }
- foreach($a as $k => $app) {
- $this->sql("INSERT INTO apps (steam_id, name, type) VALUES ('".$app[1]."', '".$app[3]."', '".$app[2]."')");
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement