protected function __construct() { parent::__construct(); $this->db = \Core\DB::getInstance(); $words = preg_split("/(?=[A-Z]+)/", get_class($this), -1, PREG_SPLIT_NO_EMPTY); $words = array_slice($words, 1); foreach ($words as $i => $word) { $words[$i] = strtolower($word); } $this->table = str_replace("model\\", "", join("_", $words)); }
public function __construct() { $this->db = DB::getInstance(); }
<?php \Core\DI::bind("App\\Models\\Game\\GameModelInterface", function () { $db = \Core\DB::getInstance(); return new \App\Models\Game\GameModel(new \App\Domain\Logic\GameLogic(new \App\Domain\Factories\ShipFactory()), new \App\Domain\Repository\Game\GameRepository(new App\Persistence\Database\GamePersistence($db), new App\Persistence\Database\ShotPersistence($db)), \Core\Session::getInstance()); });
public function __construct() { $this->db = DB::getInstance(); $this->redis = new Redis(); }
require __DIR__ . '/core/DB.PHP'; require __DIR__ . '/core/Config.php'; use core\DB; // $redis = new \Redis; // $redis -> connect('localhost','6379', 0.0); // $arr=$redis->lRange("queue_service_req",0,-1); // var_dump($arr); // // // $arr=$redis->lRange("queue_service_ing",0,-1); // var_dump($arr); // // // $redis->delete("key1"); // $redis->lPush('key1', 'sam'); // $redis->lPush('key1', 'luke'); // $redis->lPush('key1', 'boss'); // $redis->lPush('key1', 'alex'); // //var_dump($redis->lRange('key1', 0, -1)); /* array('A', 'A', 'C', 'B', 'A') */ //$redis->lRem('key1', 'luke', 1); /* 2 */ //var_dump($redis->lRange('key1', 0, -1)); /* array('C', 'B', 'A') */ //$redis->lRem('queue_service_ing','sam',1); $db = DB::getInstance(); $from_name = 'sam'; $sql = "select fd from hx_user as u,(select to_name from hx_service where from_name='{$from_name}' order by add_time desc) as s where u.u_username=s.to_name"; // echo $sql."<br>"; $result = $db->fetch_first($sql); // $rst=$result->fetch_array(MYSQLI_ASSOC); var_dump($result['fd']);
/** * @return bool */ public function delete() { $data = [':id' => $this->data['id']]; $sql = ' DELETE FROM' . ' ' . static::$schema['table'] . ' WHERE id = :id '; $db = DB::getInstance(); return $db->execute($sql, $data); }