示例#1
0
文件: Mysql.php 项目: hildalove/tiny
 public function index()
 {
     $db = Factory::getDatabase();
     $res = $db->getRow('select * from user');
     print_r($res);
     echo '<br>';
     $db->exec('UPDATE user SET password ="******" LIMIT 1');
 }
示例#2
0
文件: Proxy.php 项目: hildalove/tiny
 public function __call($method, $args)
 {
     $sql = $args[0];
     if (strtolower(substr($sql, 0, 6)) == 'select') {
         echo '读操作<br>';
         $db = Factory::getDatabase('slave');
         return call_user_func_array([$db, $method], $args);
     } else {
         echo '写操作<br>';
         $db = Factory::getDatabase('master');
         return call_user_func_array([$db, $method], $args);
     }
 }
示例#3
0
文件: User.php 项目: hildalove/tiny
 public function register()
 {
     if (!empty($_POST)) {
         var_dump($_POST);
         $username = $_POST['username'];
         $password = $_POST['password'];
         $redis = \Tiny\Service\Factory::getRedis();
         //存储用户名和密码
         $redis->set('string:user:'******'list:user', $username);
         $a = $redis->lRange('list:user', 0, -1);
         print_r($a);
         die;
     }
 }
示例#4
0
<?php

/**
 *  读取Reis里的用户注册信息队列,写入到数据库
 *  todo: 将此脚本开启自动启动
 * 问题: 写入数据库失败怎么办? 这个进行停掉了怎么办?
 */
require '../../int.inc.php';
$flag = true;
use Tiny\MessageQueue\UserMQ;
$mq = UserMQ::MQ();
while ($flag) {
    $data = $mq->pop();
    if ($data) {
        $db = \Tiny\Service\Factory::getDatabase();
        $sql = "INSERT INTO user\n        SET username = ?,\n            email = ?";
        $db->exec($sql, $data['username'], $data['email']);
    }
}
示例#5
0
文件: Home.php 项目: hildalove/tiny
 /**
  * 测试Redis连接
  */
 public function redis()
 {
     $redis = \Tiny\Service\Factory::getRedis();
     $redis->set('name', 'hanfeng');
     echo $redis->get('name');
 }
示例#6
0
文件: Model.php 项目: hildalove/tiny
 public function __construct()
 {
     $this->db = Factory::getDatabase();
 }