123456789101112131415161718192021222324252627282930313233 |
- <?php
- namespace Core;
- class User{
- protected $db;
- public function __construct()
- {
- $this->db = new \Core\Databases\Mysqli();
- $this->db->connect('39.100.75.63:33060', 'root', 'mysql57-2020!d', 'prictice');
- }
- public function getUserById($id)
- {
- $res = $this->db->query("select * from test where id=".$id)->fetch_all(MYSQLI_ASSOC)[0];
- $this->id = $res['id'];
- $this->name = $res['name'];
- $this->mobile = $res['mobile'];
- $this->regtime = $res['regtime'];
- return $this;
- }
- public function save()
- {
- $sql = "update test set name = '{$this->name}',mobile = '{$this->mobile}',regtime = '{$this->regtime}' where id = '{$this->id}'";
- $this->db->query($sql);
- }
- public function getIds()
- {
- return $this->db->query("select id from test")->fetch_all(MYSQLI_ASSOC);
- }
- }
|