Esempio n. 1
0
 public static function mysqlDemo()
 {
     self::$mysql = new MysqlClient();
     $sql = "select * from school where id = 100000";
     self::$mysql->getConnection(function ($sess) use($sql) {
         $sess->query($sql, function ($sess, $ok) {
             foreach ($sess->resultRows as $val) {
                 self::$globalData['school'][$val['id']] = $val;
             }
             print_r(self::$globalData);
         });
     });
     Debug::log('async mysql has been executed.');
 }
Esempio n. 2
0
 public static function runUpdateQuery($sqlPool, $cbEvent = null)
 {
     Instance::getMysql()->getConnection(function ($sess) use($sqlPool, $cbEvent) {
         foreach ($sqlPool as $sql) {
             $sess->query($sql, function ($sess, $ok) use($sql, $cbEvent) {
                 if ($ok) {
                     Debug::log(__METHOD__ . '() [' . $sql . '] complete run.');
                 } else {
                     Debug::error(__METHOD__ . '() [' . $sql . '] has error[' . $sess->errno . ':' . $sess->errmsg . '].');
                 }
                 if ($cbEvent instanceof CbEvent) {
                     $cbEvent->doCall($sess, $ok);
                 }
             });
         }
     });
 }
Esempio n. 3
0
 protected function onConnected($connId, $addr, $port)
 {
     Debug::log(get_class($this) . '::' . __METHOD__ . '(' . $connId . ') invoked. ');
     $sess = $this->setConnSocketSession($connId, new testClientSocketSession($this));
     $sess->write("GET / HTTP/1.1\r\nHost: 127.0.0.1\r\nConnection: Close\r\n\r\n");
 }
Esempio n. 4
0
 public function onClose()
 {
     Debug::log(get_class($this) . '::' . __METHOD__ . ' : webSocketSession onClose id[' . $this->client->getConnId() . ']');
     unset(self::$clientPool[$this->client->getConnId()]);
 }