简体   繁体   中英

Class 'Swoole\MySQL' not found

Async Mysql Client of Swoole in my PHP Project for which I am trying to use Swoole MySQL Class of PHP but I am getting

class not found

error while executing the code.

Below is the code snippet I was trying to execute:

<?php

use Swoole\MySQL as MySQL;

MySQL::connect(array(
    'host'     => 'localhost',
    'port'     => '3306',
    'user'     => 'root',
    'password' => 'Secret_Password',
    'database' => 'swoole_test_db',
    'charset'  => 'utf8',
    'timeout'  => 2,
), function ($mysql_client) {
    $mysql_client->query("SELECT `reg_id`, `name` FROM `students` WHERE `reg_id` = 8;", function ($result) {
        var_dump($result);
    });
});

I tried searching everywhere but unable to find any reference on this error.

Version Details

  • PHP 7.3.2
  • Swoole Version 4.4.3 (with Swoole MySQL selected Yes during installation)

来自phpinfo()的Swoole信息

Did I miss something, please help?

Thanks in advance!!!

It seems that the official documentation is either a bit off, or mentions a previous version of Swoole.

The class that should be used is Swoole\\Coroutine\\MySQL .

You can verify that using the official documentation in their GitHub repository .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM