gpt4 book ai didi

php - 在 yii2 查询中在哪里设置 SQL_BIG_SELECTS?

转载 作者:可可西里 更新时间:2023-11-01 07:58:30 25 4
gpt4 key购买 nike

我在执行查询时遇到错误。

SQLSTATE[42000]: Syntax error or access violation: 1104 The SELECT would examine more than MAX_JOIN_SIZE rows

我必须SET SQL_BIG_SELECTS=1

我正在使用 YII2,不知道在哪里设置 .

请帮忙。

最佳答案

来自 docs

If you need to execute a SQL query right after establishing a connection (e.g., to set the timezone or character set), you can do so in the [[yii\db\Connection::EVENT_AFTER_OPEN]] event handler.

return [
// ...
'components' => [
// ...
'db' => [
'class' => 'yii\db\Connection',
// ...
'on afterOpen' => function($event) {
// $event->sender refers to the DB connection
$event->sender->createCommand("SET SQL_BIG_SELECTS = 1")->execute();
}
],
],
// ...
];

或者在查询之前运行一次 SQL 查询:

$connection = \Yii::$app->getDb();
$res = $connection->createCommand("SET SQL_BIG_SELECTS = 1")->execute();

关于php - 在 yii2 查询中在哪里设置 SQL_BIG_SELECTS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32188158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com