| Current Path : /home/wirbesti/www/php/ |
| Current File : /home/wirbesti/www/php/FormCoordinates.php |
<?php
class FormCoordinates
{
private $con;
private $language;
// Database Connection
public function __construct(DBConnection $database, string $language)
{
$this->con = $database;
$this->language = $language;
return $this->con;
}
public function getById(int $id)
{
$query = "SELECT `canton-x`, `canton-y`, `zip-x`, `zip-y`, `town-x`, `town-y`, `birth-day-x`, `birth-day-y`, `birth-month-x`, `birth-month-y`, `birth-year-x`, `birth-year-y`, `street-x`, `street-y` FROM `nvbjn_campaign_form_coordinates` c ".
"WHERE c.campaignid = :id and c.language = :language;";
$getformcoordinates = $this->con->dbc->prepare($query);
$getformcoordinates->bindParam(':id', $id);
$getformcoordinates->bindParam(':language', $this->language);
$getformcoordinates->execute();
$result = $getformcoordinates->fetch();
return $result;
}
public function insert($data)
{
$campaignid = $data['campaignid'];
$cantonx = $data['canton-x'];
$cantony = $data['canton-y'];
$zipx = $data['zip-x'];
$zipy = $data['zip-y'];
$townx = $data['town-x'];
$towny = $data['town-y'];
$birthdayx = $data['birth-day-x'];
$birthdayy = $data['birth-day-y'];
$birthmonthx = $data['birth-month-x'];
$birthmonthy = $data['birth-month-y'];
$birthyearx = $data['birth-year-x'];
$birthyeary = $data['birth-year-y'];
$streetx = $data['street-x'];
$streety = $data['street-y'];
$cdata = [
'campaignid' => $campaignid,
'cantonx' => $cantonx,
'cantony' => $cantony,
'zipx' => $zipx,
'zipy' => $zipy,
'townx' => $townx,
'towny' => $towny,
'birthdayx' => $birthdayx,
'birthdayy' => $birthdayy,
'birthmonthx' => $birthmonthx,
'birthmonthy' => $birthmonthy,
'birthyearx' => $birthyearx,
'birthyeary' => $birthyeary,
'streetx' => $streetx,
'streety' => $streety
];
$insertSQL = "INSERT INTO `nvbjn_campaign_form_coordinates`(`campaignid`, `canton-x`, `canton-y`, `zip-x`, `zip-y`, `town-x`, `town-y`, `birth-day-x`, `birth-day-y`, `birth-month-x`, `birth-month-y`, `birth-year-x`, `birth-year-y`, `street-x`, `street-y`) ".
"VALUES (:campaignid, :cantonx, :cantony, :zipx, :zipy, :townx, :towny, :birthdayx, :birthdayy, :birthmonthx, :birthmonthy, :birthyearx, :birthyeary, :streetx, :streety)";
$result = false;
try {
$this->con->dbc->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$insertformcoordinates = $this->con->dbc->prepare($insertSQL);
$result = $insertformcoordinates->execute($cdata);
$last_id = $this->con->dbc->lastInsertId();
$this->lastid = $last_id;
} catch (PDOException $e)
{
echo $e->getMessage().' in '.$e->getFile().' on line '.$e->getLine();
}
return $result;
}
}