I have to update a field in my database when I click on a button. To do this I use a query. I am working with ZendFramework, so I use MVC model. If you have question about my code or something just ask me.
JS :
`// Gestion du bouton de Remontée en supervision
$("#remontee-supervision").click(function() {
// Suppression des filtres en session.
$.ajax({
type : 'POST',
url : '/supervision/admin/ajaxremonteesupervision',
async : true,
data : {
$idDepot : $("#idDepot").val()
},
success : function(response) {
var vResult = jQuery.parseJSON(response);
alert('remontee-supervision');
console.log(vResult.result);
if (!vResult.result) {
}
}
});
});
});`
Query:
public function putSupervision($idDepot) {
$this->executeQueries("
Update DEPOT set STATUT_DEPOT = 51103 where ID_DEPOT = ".$idDepot."
commit;"
);
return $this->getAllRows();
}
}
CONTROLLER
public function ajaxremonteesupervisionAction()
{
$this->_helper->layout->disableLayout();
$this->_helper->viewRenderer->setNoRender();
//parametre passé via ajax
$params = $this->_getAllParams();
$update = NULL;
//lancement
$oDepotAdmin = new Services_DepotAdmin();
$update = $oDepotAdmin->putSupervision();
$response['result'] = $update;
echo json_encode($response);
}
HTML
<div id="bouton">
<button id="remontee-supervision">Remontée en supervision </button>
</div>
CONSOLE

The error message is pretty clear:
Missing argument 1 for Services_DepotAdmin::putSupervision()
So, fix your code:
$update = $oDepotAdmin->putSupervision();
With
$idDepot = $params['$idDepot'];
$update = $oDepotAdmin->putSupervision($idDepot);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With