Model\Node::getNodeById PHP Method

getNodeById() public static method

Get node by Id
public static getNodeById ( $nodeId ) : mixed
$nodeId
return mixed
    public static function getNodeById($nodeId)
    {
        $statement = DB::getInstance()->prepare("SELECT * FROM node WHERE id=?");
        $statement->bindValue(1, $nodeId);
        $statement->execute();
        return $statement->fetchObject(__CLASS__);
    }

Usage Example

コード例 #1
0
ファイル: Node.php プロジェクト: sendya/shadowsocks-panel
 /**
  * @JSON
  * @return array
  */
 public function getNodeInfo()
 {
     $id = trim($_REQUEST['id']);
     $result = array('error' => -1, 'message' => 'Request failed');
     $user = User::getUserByUserId(User::getCurrent()->uid);
     $node = MNode::getNodeById($id);
     $method = $node->method;
     if ($node->custom_method == 1 && $user->method != '' && $user->method != null) {
         $method = $user->method;
     }
     $info = self::nodeDetail($node->server, $user->port, $user->sspwd, $method, $node->name);
     if (self::verifyPlan($user->plan, $node->type)) {
         $result = array('error' => 0, 'message' => '获取成功', 'info' => $info, 'node' => $node);
     } else {
         $result = array('error' => -1, 'message' => '你不是 VIP, 无法使用高级节点!');
     }
     return $result;
 }
All Usage Examples Of Model\Node::getNodeById