Помогите найти проблему
include_once '../blocks/conectbase.php';
include_once '../blocks/classes/Individ.php';
$individ = new Individ();
$individ->entryIndivid($_POST);
$individ->addSqlIndivid();
DB::getInstance()->close();
class Individ
{
private $id;
private $name_cust;
private $surname;
private $name;
private $patron;
private $gender;
private $birth;
private $serial_pasp;
private $date_pasp;
private $rovd_pasp;
private $adress;
private $phone1;
private $phone2;
private $phone3;
private $email;
private function assembleIndivid ($arr, $id_custs){
$this->id = $id_custs->id + 1;
$this->surname = $arr['surname'];
$this->name = $arr ['name'];
$this->patron = $arr ['patron'];
$this->name_cust = $this->surname.' '.$this->name.' '.$this->patron;
$this->gender = $arr ['gender'];
$this->birth = $arr ['birth'];
$date = DateTime::createFromFormat('d/m/Y', $this->birth);
$this->birth = $date->getTimestamp();
$this->serial_pasp = $arr ['serial_pasp'];
$this->rovd_pasp = $arr ['rovd_pasp'];
$this->date_pasp = $arr ['date_pasp'];
$date = DateTime::createFromFormat('d/m/Y', $this->date_pasp);
$this->date_pasp = $date->getTimestamp();
$this->adress = $arr ['adress'];
if ($arr ['phone1'] == '') {
$arr ['phone1'] = '0';
};
if ($arr ['phone2'] == '') {
$arr ['phone2'] = '0';
};
if ($arr ['phone3'] == '') {
$arr ['phone3'] = '0';
};
if ($arr ['email'] == '') {
$arr ['email'] = '0';
};
$this->phone1 = $arr ['phone1'];
$this->phone1 = preg_replace('~\D+~','',$this->phone1);
$this->phone2 = $arr ['phone2'];
$this->phone2 = preg_replace('~\D+~','',$this->phone2);
$this->phone3 = $arr ['phone3'];
$this->phone3 = preg_replace('~\D+~','',$this->phone3);
$this->email = $arr ['email'];
}
public function entryIndivid ($arr) {
$sql = 'SELECT `id` FROM `individs`
UNION SELECT `id` FROM `enterprise`
UNION SELECT `id` FROM `soleproprietor`
ORDER BY `id` DESC LIMIT 1';
$pdo = DB::getInstance()->get_pdo();
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, TRUE);
$query = $pdo -> query($sql);
$id_custs = $query->fetch(PDO::FETCH_OBJ);
$this->assembleIndivid($arr , $id_custs);
}
public function addSqlIndivid () {
$sql = 'INSERT INTO `individs`(`id`, `name_cust`, `surname`, `name`, `patron`, `gender`, `birth`, `serial_pasp`, `date_pasp`, `rovd_pasp`, `adress`, `phone1`, `phone2`, `phone3`, `email`)
VALUES (:id, :name_cust, :surname, :firstname, :patron, :gender, :birth, :serial_pasp, :date_pasp, :rovd_pasp, :adress, :phone1, :phone2, :phone3, :email)';
$pdo = DB::getInstance()->get_pdo();
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, TRUE);
$query = $pdo -> prepare($sql);
$query -> execute ([
`id` => $this->id,
`name_cust` => $this->name_cust,
`surname` => $this->surname,
`firstname` => $this->name,
`patron` => $this->patron,
`gender` => $this->gender,
`birth` => $this->birth,
`serial_pasp` => $this->serial_pasp,
`date_pasp` => $this->date_pasp,
`rovd_pasp` => $this->rovd_pasp,
`adress` => $this->adress,
`phone1` => $this->phone1,
`phone2` => $this->phone2,
`phone3` => $this->phone3,
`email` => $this->email
]);
}
};
Метод
addSqlIndivid не выполняется. Выдает PDOException: SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens.