protected function _initDb(){ $con=array('host'=>'127.0.0.1','username'=>'root', 'password'=>'','dbname'=>'sample_db'); $db=Zend_Db::factory('Pdo_Mysql',$con);$db->query("SET NAMES 'utf8'"); Zend_Registry::set('db',$db);}public function indexAction(){ $this->_helper->layout->setLayout('a');}<a href="javascript:deleteTest('62989c12369ea3c1')">DELETE</a>function deleteTest(id){ if(confirm('Are you sure?')) $.post('http://127.0.0.1/Sample4/application/models/Guestdb.php',{funcName:'Delete_Test',id:id},function(r){alert(r)})}<?phpclass Model_Guestdb{ public function Delete_Test(){ $db=Zend_Registry::get('db'); $r=$db->query("DELETE FROM `prac` WHERE `id`='".trim((new Zend_Filter_Decrypt(array('adapter'=>'mcrypt','key '=>'thisisakeytolock','vector'=>'myvector')))->filter(hex2bin($this->getRequest()->getPost()['id'])))."'"); echo$r?'t':'f'; }}$a=new Model_Guestdb();if(isset($_POST['funcName']))call_user_func(array($a,$_POST['funcName']));elseif(isset($_GET['funcName']))call_user_func(array($a,$_GET['funcName']));Fatal error: Uncaught Error: Class 'Zend_Registry' not found in C:xampphtdocsSample4applicationmodelsGuestdb .php:6 Stack trace: #0 C:xampphtdocsSample4applicationmodelsGuestdb .php(35): Model_Guestdb->Delete_Test() #1 {main} thrown in C:xampphtdocsSample4applicationmodelsGuestdb .php on line 6
برچسب:
نویسنده: خنج