search
HomeBackend DevelopmentPHP TutorialCommon problems related to the use of ZendFramework_PHP tutorial

MVC code writing:
Controller code writing:
class IndexController extends Zend_Controller_Action
{
function init()
{
$this->registry = Zend_Registry::getInstance();
$this->view = $this->registry['view'];
$this->view->baseUrl = $this->_request->getBaseUrl();

}
function indexAction()
{
$this->view->word=" I love spurs";

echo $this->view->render("index.html");

}
function addAction(){
//If it is the value from POST, increase it. Otherwise, display the add page


}
}
? >
Write content in the control: $this->view->word="ggg";
$this->view->render("index.html");
- --->index.html echo $this->word;

application->config.ini
[general]
db.adapter=PDO_MYSQL
db.config.host=localhost
db.config.username=root
db.config .password=
db.config.dbname=think_zw

The configuration file is introduced into the framework
//Configure database parameters and connect to the database
$config=new Zend_Config_Ini('./application/config/config.ini',null, true);
Zend_Registry::set('config',$config);
$dbAdapter=Zend_Db::factory($config->general->db->adapter,$config->general->db ->config->toArray());
$dbAdapter->query('SET NAMES UTF8');
Zend_Db_Table::setDefaultAdapter($dbAdapter);
Zend_Registry::set(' dbAdapter',$dbAdapter);

Single entry mode: localhost/index/add/ access the add method under the index module
function addAction(){} (in IndexController.php)
The default access is the index method under the index module

Create another message.php in the module model
class Message extends Zend_Db_Table
{
protected $_name ="message";
protected $_primary = ' id';
}
?>
Module instantiation:
function indexAction()
{
$message=new message();//instantiate database class

//Get database content
$this->view->messages=$message->fetchAll()->toArray();

echo $this->view->render('index.phtml');//Display template
}

messages as $message): ?>






******************
Modify and delete data


kk

ll

Index.phtml add Edit
Delete

Add a new method: edit.phtml
function editAction(){

$message = new Message();
$db = $message->getAdapter();

if(strtolower($_SERVER['REQUEST_METHOD'])=='post'){
$id = $this->_request->getPost('id');
$ cid = $this->_request->getPost('cid');
$title = $this->_request->getPost('title');

$set = array (
'cid'=>$cid,
'title'=>$title
);
$where = $db->quoteInto('id = ?',$id );
//Update data
$message->update($set,$where);
unset($set);
echo 'Modify data successfully! return';
}else{
$id = $this ->_request->getParam('id');
$this->view->messages = $message->fetchAll('id='.$id)->toArray();
echo $this->view->render('edit.phtml');
}
}


function delAction(){
$message = new Message();
$id = (int)$this->_request->getParam('id');

if($id > 0){
$where = 'id = ' . $id;
$message->delete($where);
}
echo 'Delete Data success! Return';
}


Exception occurred:
Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (index.php)' in

Solution: Add
$frontController->setParam('useDefaultControllerAlways', true);
after

$frontController =Zend_Controller_Front::getInstance(); in index.php

*******
id/3 is equal to the previous ?id=3

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/781925.htmlTechArticleMVC code writing: Controller code writing: ?php class IndexController extends Zend_Controller_Action { function init() { $this- registry = Zend_Registry::getInstance(); $this-view...
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
调整Windows 10的分辨率为2K调整Windows 10的分辨率为2KJan 15, 2024 am 09:57 AM

win10系统是一款可以进行各种设置与调节的个性化系统,今天小编为大家带来的就是win102k分辨率调节教程!如果你也有需要就快来看看吧。  win102k分辨率调节教程:注:想要进行分辨率两k的设置需要计算机硬件的支持。1、使用快捷键“Win+i”打开Windows设置在Windows设置窗口中,点击“系统”选项打开。2、在系统界面左侧选择显示,就可以在右侧的页面中就看到到“分辨率”的功能设置了。3、找到高级缩放设置点开就可以根据自己的需要来进行分辨率设置了!选择后点击确定即可保存。(小编的电

top交易所排名top交易所排名Mar 14, 2025 pm 06:03 PM

本文基于安全性、流动性、交易费用、用户体验、币种选择、交易功能、声誉和创新能力八大维度,深度剖析全球领先加密货币交易所,并评选出币安、欧易和芝麻开门位列前三的TOP 3排行榜。 排名考虑了交易所的交易量、交易产品多样性、用户友好度、以及安全性和监管合规性等因素。 文章将详细分析各交易所的优势和不足,并为不同类型的投资者(新手、专业交易者等)提供选择建议,助您选择最合适的加密货币交易平台。 请注意,加密货币投资高风险,本文仅供参考,不构成投资建议。

4790k支持win10系统么4790k支持win10系统么Jan 06, 2024 pm 10:21 PM

可能很多的电脑老用户还在使用4790kCPU,而面对这款处理器有很多的网友不知道是不是还可以支持win10系统,所以下面就带来了答案,一起了解看看4790k支持win10系统么。4790k支持win10系统么:答:4790k支持win10系统的。4790k其实不论win10或者win7都是可以安装的。4790k对于win7来说算是最强的硬件平台了,也是很强的ddr3游戏平台。有更换系统需求的用户不妨来下载win10试试。win10系统更多介绍:1、win10系统拥有免费的通道,都是可以去免费的接

币圈交易所排行前十app是哪些?币圈交易所排行前十app是哪些?Mar 04, 2025 pm 11:00 PM

币圈交易所是人们买卖加密货币的主要平台,选择可靠且备受推崇的交易所至关重要。本文将深入探讨业内最受欢迎的十个币圈交易所,对它们的交易量、费用、安全性和功能进行详尽分析。

十大虚拟币交易app排名榜 十大虚拟币交易app推荐十大虚拟币交易app排名榜 十大虚拟币交易app推荐Mar 19, 2025 pm 05:18 PM

本文盘点了十大值得推荐的虚拟币交易App,包括OKX、Binance、Gate.io、Kraken、Huobi、Coinbase、KuCoin、Crypto.com、Bitfinex和Gemini,排名不分先后。 这些平台在流动性、安全性、币种选择、手续费及用户体验等方面各有优势,例如OKX以其强大的流动性和便捷的用户界面著称,Binance则以全球最大的交易量和丰富的学习资源见长,Gate.io则以低手续费和丰富的币种选择吸引用户。选择虚拟币交易平台需考虑安全性、流动性、手续费、币种选择、用

不想被淘汰?学习这些PHP开发技能,拿10K不再难不想被淘汰?学习这些PHP开发技能,拿10K不再难Sep 09, 2023 pm 04:55 PM

不想被淘汰?学习这些PHP开发技能,拿10K不再难随着互联网的快速发展,网络开发领域成为了一个高薪就业的热门选择。而PHP作为一种广泛使用的服务器端脚本语言,其开发技能的掌握对于想要在网络开发领域脱颖而出的人来说至关重要。本文将介绍一些提升PHP开发技能的方法,并附加代码示例,帮助读者更好地理解和掌握这些技能。熟悉PHP框架在PHP开发中,框架是提高开发效率

虚拟币一级市场怎么玩?虚拟币一级市场怎么玩?Mar 04, 2025 pm 03:45 PM

本文介绍了虚拟币一级市场主要的几种玩法,包括私募融资、预售、天使轮融资和做市,并详细解释了每种玩法的机制、风险和潜在收益。 针对风险承受能力和投资经验不同的投资者,文章提供了相应的建议。此外,文章还推荐了多个知名的虚拟币一级市场交易平台APP,例如Binance Launchpad、OKX Jumpstart、Gate.io Startup、KuCoin Spotlight、Huobi Prime和MEXC Pioneer,并对这些平台的特点进行了简要分析,方便投资者选择合适的平台进行投资。

币圈十大交易app虚拟币平台2025权威排行榜币圈十大交易app虚拟币平台2025权威排行榜Feb 14, 2025 pm 05:09 PM

全球前十名加密货币交易所包括:币安、OKX、Gate.io、Coinbase、FTX、火币、Kraken、Crypto.com、KuCoin 和 Bitfinex。每家交易所都有其优势、劣势和潜在问题,例如庞大的用户基础、低交易费、安全性、监管合规性问题和中心化性质带来的单点故障风险。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment