PDOException: SQLSTATE[HY093]: Invalid parameter number:
Posted: Sat Oct 18, 2014 5:12 am
Code: Select all
<?php
class NewPassport extends pdoMapper
{
function __construct()
{}
function listAllNewPassportInquiry($status,$searchRefrence,$searchClientName)
{
global $page,$db;
$where = " where 1 ";
if($status != '')
{
$where .= " AND status = '".$status."' ";
}
if($searchRefrence != '')
{
$where .= " AND npid = '".$searchRefrence."' ";
}
if($searchClientName != '')
{
$where .= " AND contactname like '%".$searchClientName."%' ";
}
//set start record
$start = ($page - 1) * $_SESSION['records_perpage'];
$statement = $db->con->prepare("SELECT COUNT(*) as CNT from newpassport".$where);
$statement->execute();
if($statement->errorCode() == '00000')
{
$vals = $statement->fetch(PDO::FETCH_ASSOC);
$_SESSION['records_total'] = $vals['CNT'];
if($_SESSION['records_total'] > 0 && $_SESSION['records_total'] == $start)
{
$page = $page - 1;
$start = ($page - 1) * $_SESSION['records_perpage'];
}
$statement = $db->con->prepare("SELECT * from newpassport AS NP
LEFT JOIN users AS U ON NP.assigneduser = U.userid
".$where."
ORDER BY npid DESC
LIMIT :start, :per_page");
$statement->bindParam(":start", $start, PDO::PARAM_INT);
$statement->bindParam(":per_page", intval($_SESSION['records_perpage']), PDO::PARAM_INT);
$statement->execute();
if($statement->errorCode() == '00000')
{
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
return $result;
}
else
{
Utility::setMessage('Sorry! We have been unable to get Airline data', 'error', $statement->errorInfo());
return false;
}
}
else
{
Utility::setMessage('Sorry! We have been unable to get Airline data', 'error', $statement->errorInfo());
return false;
}
}
function insertNewPassportInquiry($post)
{
global $db;
$sql = "INSERT INTO newpassport (contactname ,applyingfor, contactway, contactwayother, inquiryfor,
mobilenumber, landlinenumber, emailid, address, inquirydescription, inquirydate, assigneduser,status) "
. " VALUES (:contactname, :referrence, :contactway, :contactwayother, :inquiryfor,
:mobilenumber, :landlinenumber, :emailid, :address, :inquirydescription, NOW(), :assigneduser,1
)";
$statement =$db->con->prepare($sql);
$statement->bindParam(":contactname", $post['contactname']);
$statement->bindParam(":applyingfor", $post['applyingfor']);
$statement->bindParam(":contactway", $post['contactway']);
$statement->bindParam(":contactwayother", $post['contactwayother']);
$statement->bindParam(":inquiryfor", $post['inquiryfor']);
$statement->bindParam(":mobilenumber", $post['mobilenumber']);
$statement->bindParam(":landlinenumber", $post['landlinenumber']);
$statement->bindParam(":emailid", $post['emailid']);
$statement->bindParam(":address", $post['address']);
$statement->bindParam(":inquirydescription", $post['inquirydescription']);
$statement->bindParam(":assigneduser", $post['assigneduser']);
$statement->execute();
if($statement->errorCode() == '00000')
{
return $db->con->lastInsertId();
}
else
{
Utility::setMessage('Sorry! We have been unable to insert Airline data', 'error', $statement->errorInfo());
return false;
}
}
function updateNewPassportInquiry($post)
{
global $db;
$sql = "UPDATE newpassport SET contactname = :contactname,
applyingfor = :applyingfor,
contactway = :contactway,
contactwayother = :contactwayother,
inquiryfor = :inquiryfor,
mobilenumber = :mobilenumber,
landlinenumber = :landlinenumber,
emailid = :emailid,
address = :address,
inquirydescription = :inquirydescription,
assigneduser = :assigneduser
WHERE npid = :npid ";
$statement =$db->con->prepare($sql);
$statement->bindParam(":contactname", $post['contactname']);
$statement->bindParam(":applyingfor", $post['applyingfor']);
$statement->bindParam(":contactway", $post['contactway']);
$statement->bindParam(":contactwayother", $post['contactwayother']);
$statement->bindParam(":inquiryfor", $post['inquiryfor']);
$statement->bindParam(":mobilenumber", $post['mobilenumber']);
$statement->bindParam(":landlinenumber", $post['landlinenumber']);
$statement->bindParam(":emailid", $post['emailid']);
$statement->bindParam(":address", $post['address']);
$statement->bindParam(":inquirydescription", $post['inquirydescription']);
$statement->bindParam(":assigneduser", $post['assigneduser']);
$statement->bindParam(":npid", $post['npid']);
$statement->execute();
if($statement->errorCode() == '00000')
{
return true;
}
else
{
Utility::setMessage('Sorry! We have been unable to insert Airline data', 'error', $statement->errorInfo());
return false;
}
}
function getNewPassportInquiryDetail($npid)
{
global $db;
$sql = "SELECT NP.*,U.firstname,U.lastname FROM newpassport as NP
LEFT JOIN users as U on NP.assigneduser = U.userid
WHERE NP.npid = :npid ";
$statement = $db->con->prepare($sql);
$statement->bindParam(":npid", $npid);
$statement->execute();
if($statement->errorCode() == '00000')
{
$result = $statement->fetch(PDO::FETCH_ASSOC);
return $result;
}
else
{
Utility::setMessage('Sorry! We have been unable to get Airline data', 'error', $statement->errorInfo());
return false;
}
}
function deleteNewPassportInquiry($npid)
{
global $db;
$sql = "DELETE FROM newpassport WHERE npid = :npid";
$statement = $db->con->prepare($sql);
$statement->bindParam(":npid", $npid);
$statement->execute();
if($statement->errorCode() == '00000')
{
return true;
}
else
{
Utility::setMessage('Sorry! We have been unable to delete Airline data', 'error', $statement->errorInfo());
return false;
}
}
}
?>