【发布时间】:2013-07-28 16:12:45
【问题描述】:
如果用户填写表格并插入 1 或更高版本,则一些表格字段是 int(11) 可以正常工作,但是当他们插入零时,我遇到了很大的麻烦并且它不起作用。 我如何获得以下脚本以将 0 作为 int 插入
<?php
class add_qual {
private $db;
public function __construct(){
$this->db = new connection();
$this->db = $this->db->dbconnect();
}
public function new_qual($user_id,
$providers,
$code,
$title,
$title_under,
$full_title,
$description,
$comments,
$level,
$expires,
$period_months
$is_superceded) {
$flag='';
if($user_id==''){$flag='error'; }
if($providers==''){$flag='error'; }
if($title==''){$flag='error'; }
if($expires==''){$flag='error'; }
{$flag='error'; }
if ($flag=='') {
//if($user_id!=''){
$st = $this->db->prepare("INSERT INTO national_body_qualifications_list
(user_id,
providers,
code,
title,
title_under,
full_title,
description,
comments,
level,
expires,
period_months,
is_superceded )
VALUES (?,?,?,?,?,?,?,?,?,?)");
$st->bindParam(1, $user_id);
$st->bindParam(2, $providers);
$st->bindParam(3, $code);
$st->bindParam(4, $title);
$st->bindParam(5, $title_under);
$st->bindParam(6, $full_title);
$st->bindParam(7, $description);
$st->bindParam(8, $comments);
$st->bindParam(9, $level);
$st->bindParam(10, $expires);
$st->bindParam(11, $period_months);
$st->bindParam(12, $is_superceded);
$st->execute();
echo 'Yay it worked';
} else {
echo 'Max Fail';
}
}
}
?>
【问题讨论】:
-
标题和描述没有多大意义。无论如何,您为什么不尝试仅处理
try{}和catch()例外情况? -
只是一个笔记集
$flag = 0不是$flag =''。还有if($user_id===''){$flag=1; }etc
标签: php pdo int sqlbindparameter