PHP:
скопировать код в буфер обмена
скопировать код в буфер обмена
- class DB
- {
- function connect()
- {
- $db = new mysqli("localhost", "user", "pass", "bd");
- $db->query("SET CHARSET SET utf8");
- $db->query("SET NAMES 'utf8'");
- $this->query = $db;
- return $db;
- }
- function select($select)
- {
- if ($result = $this->query->query($select))
- {
- if($result->num_rows > 0)
- {
- $row = $result->fetch_assoc();
- return $row;
- }
- else
- {
- return FALSE;
- }
- }
- else
- {
- return FALSE;
- }
- $result->close();
- }
- }
- $DB = new DB();
- $DB->connect();
- $select = $DB->select("SELECT `name` FROM `users` WHERE `id`='1'");
- echo $select['name'];