Why my model function doesn't work in ZEND? -


i'm wondering wrong code : function controller :

public function testareaction(){      // $this->getresponse()->setheader('content-type', 'application/json');     $this->_helper->layout->disablelayout();     $this->_helper->viewrenderer->setnorender(true);     //$myarray =  $_post['data_post'];     //$product_ids = $_post['product_ids'];     //$type = 1;     $model = new application_model_order();      echo $model -> saveordernames(); } 

and function model :

public function saveordernames(){     return 1; } 

why im not getting result "1" in browser?
im newbie please give me speficitions.

thx :d index controller :

public function indexaction()     {         if (!($locationurl = $this->_getparam('locationurl'))) {             throw new \zend_controller_action_exception('location url not provided.', 404);         }                  $this->maidivclass = "block clear step1";          // location row         $mapper = new dbtable\location();         $sql = $mapper->select()->where('url = ?', $locationurl);          if (!($this->view->location = $mapper->fetchrowactive($sql))) {             throw new \zend_controller_action_exception('location not found', 404);         }          // set active markup location menu         $this->_helper->layout()->locationmainmenuurl = $this->view->location->url;          // seo         $this->setseo(             $this->view->location->meta_title,              $this->view->location->meta_description,              $this->view->location->meta_keywords         );          // day param         $dayname = $this->_getparam('day', cronos::getcurrentdayname());          $this->view->dayno = cronos::getweekdaynumber($dayname);         if ($this->view->dayno === false) {             throw new \zend_controller_action_exception('invalid weekday provided.', 404);         }          $this->view->selecteddate = cronos::getdatewithoffset($this->view->dayno); // date offset         $this->view->categmapper  = new dbtable\categories();          $appcfg = new zend_config_ini(application_path . '/configs/application.ini', application_env);         $this->view->s3 = "http://".$appcfg->custom->s3->bucket;         $imgmapper = new application_model_mapper_images();         $this->view->imgs = $imgmapper->fetchallbylocationid($this->view->location->id);           /**          * show products allowed admin emails. testing only.          * admin must logged in see products, while test on.          *           * disable, change custom.test.isenabled flag in app.ini.          */         $testcfg = zend_registry::get('zend_config')->custom->test->toarray();         $isenabled = (bool) $testcfg['isenabled'];          // test enabled?         if ($isenabled) {             $email = false;              $auth  = zend_auth::getinstance();             // grab email, if logged in             if ($auth->hasidentity()) { $email = $auth->getidentity()->email; }              // has email? check against config, else don't show products             $showproducts = ($email) ? in_array($email, (array) $testcfg['email']) : false;          // test disabled: show products         } else {             $showproducts = true;         }          if ($showproducts) {              // categories & products date , location             $prodservice = new \application\service\products();             $this->view->categswithprods = $prodservice->getproducts($this->view->location->id, $this->view->selecteddate);               //check days of week products             $week = array();             $currentday = cronos::getweekdaynumberbydate();             if($this->view->location->erp_name != "city lbox") {                 for($day=$currentday;$day<7;$day++)                 {                     $selecteddate = cronos::getdatewithoffset($day);                     $categswithprod = $prodservice->getproducts($this->view->location->id, $selecteddate);                     if(count($categswithprod))                         $week[] = $day;                  }                 //we need go sunday , next week                 for($day=0;$day<$currentday;$day++)                 {                     $selecteddate = cronos::getdatewithoffset($day);                     $categswithprod = $prodservice->getproducts($this->view->location->id, $selecteddate);                     if(count($categswithprod))                         $week[] = $day;                 }              } else {                 for($day = $currentday; $day<7;$day++) {                     $week[] = $day;                 }                 for($day = 0; $day<$currentday; $day++) {                     $week[] = $day;                 }             }              $this->view->week = $week;             $specialmenurows = $this->view->location->getspecialmenus(new zend_date());             $this->view->specialmenus = $this->view->partial('_partials/specialmenu.phtml', array('specialmenus' => $specialmenurows));              $this->view->categswithprodsalacarte =  $prodservice->getproducts($this->view->location->id, $this->view->selecteddate, 1);          // no xml; show "download pdf"         } else {             $this->setpdflink();             $this->renderscript('location/no_xml.phtml');         }     } 

ok , created in models folder file : ordernames.php , model contains :

<?php     class ordernames {          public function saveordernames(){                  return 1;                 }      }    ?>  

and function controller :

public function testareaction(){          $this->_helper->layout->disablelayout();         $this->_helper->viewrenderer->setnorender(true);         echo "1tralala";         $model = new application_model_ordernames();          echo "2<hr>";         $model -> saveordernames();  } 

why string "2tralala" doesnt appear ?

you call: $model = new application_model_ordernames();
name of php file ordernames.php
, class is

class ordernames {      public function saveordernames(){              return 1;             }  }    

so try replace name of class:

class application_model_ordernames {... 

Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -