php - Exception information: Message: SQLSTATE[HY093]: Invalid parameter number: no parameters were bound -
i have code here that, has search , post information selected in table above add button, search works im having problem post table function. these lines shows have errors.
c:\xampp\htdocs\portal-gep-2\application\models\serviceproviders.php(68): zend_db_table_abstract->fetchrow(object(zend_db_table_select))
public function getname($id) { $select = $this->select(); $select->where('service_provider_id = ?', $id); $result = $this->fetchrow($select); //this line return $result['service_provider_name']; }
#6 c:\xampp\htdocs\portal-gep-2\application\modules\admin\controllers\ajaxcontroller.php(1104): model_serviceproviders->getname(null)
public function postserviceprovideraction() { $form = new form_industrialtable(); $this->view->form = $form; if(!$form->isvalid($_post)) { $values=$form->getvalues(); } $sp = $this->getrequest()->getpost('serviceprovider', null); $mdlserviceprovider = new model_serviceproviders(); $serviceprovider = $mdlserviceprovider ->getname($id); //this line $rtn_array= array( 'sp' => $sp, 'serviceprovider ' => $serviceprovider); $this->_helper->layout->disablelayout(); $this->_helper->viewrenderer->setnorender(); echo zend_json::encode($rtn_array); }
you don't put initial value $id
it's null
causes error.
you want sql query select * service_providers service_provider_id = 50
, have provide id want find (50 in example). need add value variable $id
before using in $select->where('service_provider_id = ?', $id);
, code never put value variable $id
.
if i'm guessing idea need change line:
$serviceprovider = $mdlserviceprovider ->getname($id);
to:
$serviceprovider = $mdlserviceprovider ->getname($sp);
also part of code unnecessary nothing:
$form = new form_industrialtable(); $this->view->form = $form; if(!$form->isvalid($_post)) { $values=$form->getvalues(); //you never use $values }
Comments
Post a Comment