我在上述查询的accepted_join_id中发现输入的user_id给出错误,因为 语法错误,意外的'$ user_id'(T_VARIABLE)
$query=DB::select('select activity_id,accepted_join_id from table_user_create_activity WHERE FIND_IN_SET('$user_id',?) and activity_id=?',[$user_id,$accepted_join_id]);
答案 0 :(得分:0)
如果您想将php中的$ user_id值注入查询中,请尝试以下操作:
$query=DB::select('select activity_id,accepted_join_id from table_user_create_activity WHERE FIND_IN_SET('.$user_id.',?) and activity_id=?',[$user_id,$accepted_join_id]);
或者如果$ user_id在查询中,则应为:
$query=DB::select('select activity_id,accepted_join_id from table_user_create_activity WHERE FIND_IN_SET("$user_id",?) and activity_id=?',[$user_id,$accepted_join_id]);