Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
后端开发代码/编码规范 – 扎老铁
Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215

Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
Warning: mysqli_num_fields() expects parameter 1 to be mysqli_result, boolean given in /www/wwwroot/dev.zhalaotie.com/wp-includes/wp-db.php on line 3215
class="post-52837 post type-post status-publish format-standard hentry">

后端开发代码/编码规范

 

对于查询参数,用参数化的方式,不要用拼接SQL字符串的方式

public void DeleteDeviceInGroupByDeviceId(string deviceId)
{
            string sqlalert = string.Format("DELETE FROM `bx_bitlab_iot_deviceingroup` where DeviceDefId='{0}'", deviceId); 
            var alertcount = Session.CreateSQLQuery(sqlalert);

}

即把那些string.format占位符的写法,改为 SQL 参数 SetParameter 的写法

 

 

 

 

 

发表评论

电子邮件地址不会被公开。