[10501] PDOException in Connection.php line 385

SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'userName' in where clause is ambiguous

  1. $this->PDOStatement->execute();
  2. // 调试结束
  3. $this->debug(false, '', $master);
  4. // 返回结果集
  5. return $this->getResult($pdo, $procedure);
  6. } catch (\PDOException $e) {
  7. if ($this->isBreak($e)) {
  8. return $this->close()->query($sql, $bind, $master, $pdo);
  9. }
  10. throw new PDOException($e, $this->config, $this->getLastsql());
  11. } catch (\Throwable $e) {
  12. if ($this->isBreak($e)) {
  13. return $this->close()->query($sql, $bind, $master, $pdo);
  14. }
  15. throw $e;
  16. } catch (\Exception $e) {
  17. if ($this->isBreak($e)) {
  18. return $this->close()->query($sql, $bind, $master, $pdo);
  19. }

Call Stack

  1. in Connection.php line 385
  2. at Connection->query('SELECT COUNT(*) AS t...', ['where_AND_userName' => ['zzu', 2]], false, true) in Query.php line 255
  3. at Query->query('SELECT COUNT(*) AS t...', ['where_AND_userName' => ['zzu', 2]], false, true) in Query.php line 2470
  4. at Query->getPdo() in Query.php line 441
  5. at Query->value('COUNT(*) AS tp_count', 0, true) in Query.php line 576
  6. at Query->aggregate('COUNT', '*', true) in Query.php line 551
  7. at Query->count() in Query.php line 1484
  8. at Query->paginate(20) in Index.php line 41
  9. at Index->index() in Index.php line 14
  10. at Index->index()
  11. at ReflectionMethod->invokeArgs(object(Index), []) in App.php line 343
  12. at App::invokeMethod([object(Index), 'index'], []) in App.php line 611
  13. at App::module(['index', 'index', 'index'], ['app_host' => '', 'app_debug' => true, 'app_trace' => false, ...], true) in App.php line 456
  14. at App::exec(['type' => 'module', 'module' => ['index', 'index', 'index']], ['app_host' => '', 'app_debug' => true, 'app_trace' => false, ...]) in App.php line 139
  15. at App::run() in start.php line 19
  16. at require('/www/wwwroot/51zuso....') in index.php line 20

Exception Datas

PDO Error Info
SQLSTATE 23000
Driver Error Code 1052
Driver Error Message Column 'userName' in where clause is ambiguous
Database Status
Error Code 10501
Error Message SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'userName' in where clause is ambiguous
Error SQL SELECT COUNT(*) AS tp_count FROM `bbs_article` `a` INNER JOIN `bbs_member` `b` ON `a`.`userName`=`b`.`userName` WHERE `userName` = 'zzu' AND `a`.`userName` = 'admin' AND `a`.`key` = '' LIMIT 1
Database Config
type mysql
hostname 127.0.0.1
database 51zuso_com
hostport
dsn
params []
charset utf8
prefix bbs_
debug true
deploy 0
rw_separate false
master_num 1
slave_no
read_master false
fields_strict true
result_type 2
resultset_type \think\Collection
auto_timestamp false
datetime_format Y-m-d H:i:s
sql_explain false
builder
query \think\db\Query
break_reconnect false

Environment Variables

GET Data
empty
POST Data
empty
Files
empty
Cookies
empty
Session
empty

Server/Request Data

USER
www
HOME
/home/www
HTTP_HOST
www.51zuso.com
HTTP_USER_AGENT
claudebot
HTTP_ACCEPT
*/*
PATH_INFO
/index/index/userName/zzu.html
REDIRECT_STATUS
200
SERVER_NAME
www.51zuso.com
SERVER_PORT
80
SERVER_ADDR
172.22.30.58
REMOTE_PORT
47860
REMOTE_ADDR
54.224.52.210
SERVER_SOFTWARE
nginx/1.18.0
GATEWAY_INTERFACE
CGI/1.1
REQUEST_SCHEME
http
SERVER_PROTOCOL
HTTP/1.1
DOCUMENT_ROOT
/www/wwwroot/51zuso.com/public
DOCUMENT_URI
/index.php
REQUEST_URI
/index/index/userName/zzu.html
SCRIPT_NAME
/index.php
CONTENT_LENGTH
CONTENT_TYPE
REQUEST_METHOD
GET
QUERY_STRING
s=/index/index/userName/zzu.html
SCRIPT_FILENAME
/www/wwwroot/51zuso.com/public/index.php
FCGI_ROLE
RESPONDER
PHP_SELF
/index.php
REQUEST_TIME_FLOAT
1710821331.3173
REQUEST_TIME
1710821331
Environment Variables
empty

ThinkPHP Constants

APP_PATH
/www/wwwroot/51zuso.com/public/../app/
CONF_PATH
/www/wwwroot/51zuso.com/public/../config/
THINK_VERSION
5.0.24
THINK_START_TIME
1710821331.318
THINK_START_MEM
405664
EXT
.php
DS
/
THINK_PATH
/www/wwwroot/51zuso.com/thinkphp/
LIB_PATH
/www/wwwroot/51zuso.com/thinkphp/library/
CORE_PATH
/www/wwwroot/51zuso.com/thinkphp/library/think/
TRAIT_PATH
/www/wwwroot/51zuso.com/thinkphp/library/traits/
ROOT_PATH
/www/wwwroot/51zuso.com/
EXTEND_PATH
/www/wwwroot/51zuso.com/extend/
VENDOR_PATH
/www/wwwroot/51zuso.com/vendor/
RUNTIME_PATH
/www/wwwroot/51zuso.com/runtime/
LOG_PATH
/www/wwwroot/51zuso.com/runtime/log/
CACHE_PATH
/www/wwwroot/51zuso.com/runtime/cache/
TEMP_PATH
/www/wwwroot/51zuso.com/runtime/temp/
CONF_EXT
.php
ENV_PREFIX
PHP_
IS_CLI
false
IS_WIN
false