Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CALL `add_full`('game 1', 2222645576, 'http://info.com/data/1234', '2018-03-01 19:01:11')
- class Database
- {
- private static $user = "root";
- private static $pass = "test";
- private static $db = "db";
- private static $server = "localhost";
- private $conn;
- private static $add_full_sp = "add_full";
- public function __construct()
- {
- $this->conn = new mysqli(self::$server, self::$user, self::$pass, self::$db);
- if ($this->conn->connect_error) {
- throw new Exception("Connection failed: " . $conn->connect_error);
- }
- }
- public function __destruct()
- {
- $this->conn->close();
- }
- public function addFull($name, $size, $url, $date)
- {
- $call = "CALL `" . self::$add_full_sp . "`('" . $name . "', " . $size . ", '" . $url . "', '".$date."')";
- //var_dump($call);
- $this->conn->query($call);
- }
- }
- $db = new Database();
- foreach($json as $item) {
- if(array_search($item, $list)) {
- continue;
- }
- $bytes = round(textToSize($item->size));
- $date = $item->date; // it is 2018-03-01 12:12:12
- $db->addFull($item->name, $bytes, $item->url, $date);
- }
Add Comment
Please, Sign In to add comment