mysql count user_为什么mysql中select count(username) from exeruser where username='留意';得到结果1,但代码中却是0...

具体代码:<?phprequire ("mysqlConn.php");require("Register.php");var_dump(Register::insertUser("留意","1234567"));?>mysqlConn代码:<?php //数据库连接文件$conn=mysql_connect...

具体代码:

require( "mysqlConn.php" );

require( "Register.php" );

var_dump(Register::insertUser( "留意", "1234567" ));

?>

mysqlConn代码:

//数据库连接文件

$conn = mysql_connect( "localhost", "root", "123456" );

mysql_select_db( "dbtest", $conn );

?>

Register代码:

class Register

{

//插入用户数据

static function insertUser( $userName, $userPwd )

{

$judgeLink = mysql_query( "select count(username) from exeruser where username='{$userName}'" );

echo "select count(username) from exeruser where username='{$userName}'"; //查看select语句是否有误

$judge = mysql_fetch_row( $judgeLink );

var_dump($judge); //查看返回的具体结果

if( $judge[0] )

{

return "有相同用户名!";

}

return mysql_query( "insert into exeruser(username,pwd) values( {$userName},{$userPwd} )" );

}

运行后的具体结果:

select count(username) from exeruser where username='留意'array(1) { [0]=> string(1) "0" } bool(false)

展开

have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':remark OR :remark IS NULL)\n AND (s.ftype_id = :ftype_id OR :ftype_' at line 8") def fetch_data_api_mode(platforms, remark, user_id=None, ftype_id=None, inviter_id=None, page=None, page_size=None): table_name_strategy_mapping = { 'okx': 'strategy_okxapimode', 'binance': 'strategy_bnapimode', # 添加其他平台的映射关系 } table_names_strategy = [table_name_strategy_mapping[p] for p in platforms] union_queries = [] for strategy in table_names_strategy: union_query = f""" SELECT s.id, s.create_time, s.update_time, s.ftype_id, s.active, s.user_id, s.platform, s.remark, s.inviter_id, s.user_id, u.username AS username, s.inviter_id, u_inviter.username AS inviter_name FROM {strategy} AS s LEFT JOIN system_user AS u ON s.user_id = u.id LEFT JOIN system_user AS u_inviter ON s.inviter_id = u_inviter.id WHERE (s.remark = :remark OR :remark IS NULL) AND (s.ftype_id = :ftype_id OR :ftype_id IS NULL) AND (s.user_id = :user_id OR :user_id IS NULL) AND (s.inviter_id = :inviter_id OR :inviter_id IS NULL) """ union_queries.append(union_query) query = f""" SELECT id, create_time, update_time, ftype_id, active, user_id, platform, remark, inviter_id, inviter_name,user_id,username FROM ({' UNION ALL '.join(union_queries)}) AS combined_tables ORDER BY create_time DESC LIMIT :page_size OFFSET :offset """ count_query = f""" SELECT COUNT(*) AS total_count FROM ({' UNION ALL '.join(union_queries)}) AS combined_tables """ query_parms = { 'remark': remark, 'ftype_id': ftype_id, 'user_id': user_id, 'inviter_id': inviter_id, 'page_size': page_size, 'offset': (page - 1) * page_size if page is not None and page_size is not None else None } result = execute_raw_sql_query(query, query_parms) count_result = execute_raw_sql_query(count_query, query_parms) return result, count_result[0]['total_count']
07-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值