Comments (6)
是用的 Swoole\Coroutine\MySQL
吗?这个已经不推荐使用了
from swoole-src.
和推荐不推荐没关系、这意味着整个4.x到5.x都有bug。这线上用的咋办
from swoole-src.
无法复现
代码:
<?php
declare(strict_types=1);
use Swoole\Coroutine\MySQL;
// mysqli
$mysqli = new \mysqli('127.0.0.1', 'root', 'root', 'swoole');
$mysqli->query('TRUNCATE student_score');
$stmt = $mysqli->prepare('INSERT INTO `student_score` (`scoreId`, `studentId`, `courseId`, `score`) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE `score` = ?');
$stmt->execute([1,1,1,1,1]);
var_dump($stmt->insert_id, $stmt->affected_rows);
$stmt->execute([1,1,1,1,1]);
var_dump($stmt->insert_id, $stmt->affected_rows);
// swoole
Co\run(function(){
$mysql = new MySQL();
$mysql->connect([
'host' => '127.0.0.1',
'port' => 3306,
'user' => 'root',
'password' => 'root',
'database' => 'swoole',
]);
$mysql->query('TRUNCATE student_score');
$stmt = $mysql->prepare('INSERT INTO `student_score` (`scoreId`, `studentId`, `courseId`, `score`) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE `score` = ?');
$stmt->execute([1,1,1,1,1]);
var_dump($stmt->insert_id, $stmt->affected_rows);
$stmt->execute([1,1,1,1,1]);
var_dump($stmt->insert_id, $stmt->affected_rows);
});
结果:
# php test.php
int(1)
int(1)
int(0)
int(0)
int(1)
int(1)
int(0)
int(0)
from swoole-src.
重新测试中
from swoole-src.
//swoole mysql
$ret = $stmt->execute([1,1,1,time(),1]);
var_dump($ret);
$ret = $stmt->execute([1,1,1,time(),1]);
var_dump($ret);
var_dump($stmt->fetchAll());
// mysqli
$ret = $stmt->execute([1,1,1,1,1]);
var_dump($stmt->get_result());
$stmt = $mysqli->prepare('INSERT INTO `student_score` (`scoreId`, `studentId`, `courseId`, `score`) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE `score` = ?');
$ret = $stmt->execute([1,1,1,time(),1]);
var_dump($stmt->get_result());
mysqli的返回是false,swoole的都是true。id那个我换了环境好了
from swoole-src.
这边测试 execute()
返回值都是 true
mysqli 的 get_result()
返回 false
swoole 的 fetchAll()
返回空数组
框架层面做好兼容就行了
from swoole-src.
Related Issues (20)
- Uncaught Swoole\Error: cURL is executing, cannot be operated in HOT 8
- swoole 4.8-5.0版本使用redis异常 HOT 5
- Swoole CURL Flag causes SEGFAULT on PHP8.3 HOT 2
- Compile and install Swoole 5.1.1, run the make test command and output a large number of errors HOT 1
- abnormal exit HOT 3
- curl协程化无法通过curl_getinfo获取tcp连接时长等数据 HOT 4
- 编译报错 HOT 2
- 开启native curl后性能远不及未开启native curl HOT 2
- MySQL server fails connection at ./init of test HOT 1
- typo report: UNKOWN
- Urgent Request for 'curl' Bug Fix Release HOT 2
- swoole 5.1.1 线上运行一段时间后,容易出现假死现象 HOT 2
- PECL release of swoole 5.1.2 HOT 8
- syntax error near unexpected token `SQLITE,' HOT 1
- CURLOPT_SHARE option is not supported in Swoole 5.0.3 HOT 1
- Segmentation fault when calling blocking function inside coroutine HOT 2
- make test error report HOT 1
- 实际上5.1.1的一键协程化,很多是不能用的,swoole会报错,理想很丰满,现实很骨感,还是得用之前得协程客户端 HOT 1
- Swoole\Coroutine\FastCGI\Client设置了withKeepConn为true仍然无法复用同一个连接 HOT 6
- Server::check_worker_exit_status(): worker(pid=3169, id=1) abnormal exit, status=0, signal=11 HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from swoole-src.