Last active
March 31, 2022 13:31
-
-
Save paulodutra/517d0acbfec042979669ae7c3bc7e470 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Sql { | |
public $conn; | |
public function __construct(){ | |
return $this->conn = mysqli_connect("127.0.0.1","root","","hcode_shop"); | |
} | |
public function query($string_query){ | |
return mysqli_query($this->conn, $string_query); | |
} | |
public function select($string_query){ | |
$result = $this->query($string_query); | |
$data = array(); | |
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { | |
foreach ($row as $key => $value) { | |
$row[$key] = utf8_encode($value); | |
} | |
array_push($data, $row); | |
} | |
unset($result); | |
return $data; | |
} | |
public function __destruct(){ | |
mysqli_close($this->conn); | |
} | |
} | |
$a = new Sql(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment