示例我有这样的数组:
Array
(
[0] => 2010140419
[1] => 2010140420
[2] => 20101140421
)
我创建这样的代码:
public function check_siswa($noInduk) {
$cnoInduk = count($noInduk);
for($i = 0; $i < $cnoInduk; $i++) {
$sql = "SELECT no_induk FROM siswa WHERE no_induk = :noInduk";
$q = $this->db->conn_id->prepare($sql);
$q->bindParam(':noInduk', $noInduk[$i], PDO::PARAM_INT);
$q->execute();
}
$q->rowCount();
$result = $q->fetchColumn();
print_r($result);
exit();
}
从上面的代码,结果我得到:
2010140420
我有这样的数据库:
SELECT no_induk from siswa;
no_induk
------------
2010140419
2010140420
我的问题,如何获得结果错误 no_induk 2010140419 和 2010140420 已经存在?