try{
$sql="INSERT INTO ad (id_user,id_categoria_level_1,id_categoria_level_2,id_categoria_level_3,name_ad,desc_ad,
price,video,link,time_ad,public,time_do)
VALUES ( :id_user,:id_categoria_level_1,:id_categoria_level_2,:id_categoria_level_3,:name_ad,:desc_ad,:price,:video,:link,$timeAd,'YES',$timeDo)";
$db=Db::getConnection();
$db->beginTransaction();
$query=$db->prepare($sql);
$query->bindParam(':id_user',$user['id'],PDO::PARAM_INT);
$query->bindParam(':id_categoria_level_1',$id_kat,PDO::PARAM_STR);
$query->bindParam(':id_cate2goria_level_2',$id_podkat_one,PDO::PARAM_STR);
$query->bindParam(':id_categoria_level_3',$id_podkat_two,PDO::PARAM_STR);
$query->bindParam(':name_ad',$dataName,PDO::PARAM_STR);
$query->bindParam(':desc_ad',$dataDescription,PDO::PARAM_STR);
$query->bindParam(':price',$dataPrice,PDO::PARAM_INT);
$query->bindParam(':video',$video,PDO::PARAM_STR);
$query->bindParam(':link',$link,PDO::PARAM_STR);
$res=$query->execute();
$numberId=$db->lastInsertId();
if($res){
Self::InsertDataСitySql($db,$numberId,$cityId,$dataLon,$dataLat,$dataStreet,$dataNumber);
}
$db->commit();
} catch (\PDOException $e){
echo $e->getMessage();
echo "catch";
$db->rollBack();
}