コード例 #1
0
function insert2($postData)
{
    echo dump($postData);
    $connection = connect();
    echo dump($postData['applicant']);
    $gardian = new Applicant();
    $applicant = $postData['applicant'];
    $gardian->setNameInFull(mysqli_real_escape_string($connection, $applicant['nameInFull']));
    $gardian->setNameInInitials(mysqli_real_escape_string($connection, $applicant['nameInInitials']));
    $gardian->setPermanentAddress(mysqli_real_escape_string($connection, $applicant['permanentAddress']));
    $gardian->setGramaNiladariDivion(mysqli_real_escape_string($connection, $applicant['gramaNiladariDivion']));
    $gardian->setDivsionalScretaryArea(mysqli_real_escape_string($connection, $applicant['divsionalScretaryArea']));
    $gardian->setDistrict(mysqli_real_escape_string($connection, $applicant['district']));
    $gardian->setNic(mysqli_real_escape_string($connection, $applicant['nic']));
    $gardian->setReligion(mysqli_real_escape_string($connection, $applicant['religion']));
    $gardian->setWetherSrilankan($applicant['wetherSrilankan']);
    $gardian->setNoYearsInElectoralRegister($applicant['noYearsInElectoralRegister']);
    $query = "insert into applicant (";
    $query .= " name_in_full,name_in_initials, permanent_address, grama_niladari_divion,divsional_scretary_area,district,nic,wether_srilankan,no_years_in_electoral_register,religion";
    $query .= ") values( ";
    $query .= " '{$gardian->getNameInFull()}','{$gardian->getNameInInitials()}','{$gardian->getPermanentAddress()}','{$gardian->getGramaNiladariDivion()}','{$gardian->getDivsionalScretaryArea()}','{$gardian->getDistrict()}','{$gardian->getNic()}','{$gardian->getWetherSrilankan()}','{$gardian->getNoYearsInElectoralRegister()}','{$gardian->getReligion()}'";
    $query .= ")";
    $result = mysqli_query($connection, $query);
    if ($result) {
        // echo dump($result);
        $query = "select id from applicant where name_in_full= '{$gardian->getNameInFull()}' and nic = '{$gardian->getNic()}' LIMIT 1";
        $result = mysqli_query($connection, $query);
        confirm_query($result);
        $row = mysqli_fetch_assoc($result);
        colse_connection($connection);
        //echo dump($row);
        return $row['id'];
    }
    colse_connection($connection);
    return null;
}
 /**
  * {@inheritDoc}
  */
 public function setDivsionalScretaryArea($divsionalScretaryArea)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDivsionalScretaryArea', array($divsionalScretaryArea));
     return parent::setDivsionalScretaryArea($divsionalScretaryArea);
 }