Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to configure the operation database for zend framework

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "zend framework how to configure the operation database", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "zend framework how to configure the operation of the database" this article.

After building the zendframework project environment, take a look at the zendframework configuration operation database. The php tutorials are as follows:

Create a config.ini file under the application/configs file

The configuration information is as follows:

[general]

Db.adapter=PDO_MYSQL

Db.config.host=localhost/IParess

Db.config.username=username

Db.config.password=password

Db.config.dbname=databasename

2 、

In the index.php page of the pulibc directory

/ * * Zend_Application * /

Require_once 'Zend/Application.php'

Insert under the

/ / set the datase config

Require_once 'Zend/Config/Ini.php'

Require_once 'Zend/Registry.php'

Require_once 'Zend/Db.php'

Require_once 'Zend/Db/Table.php'

$config=new Zend_Config_Ini ('. /.. / application/configs/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)

At this point, I'll test it with my local wordpress database, and test it with the wp_posts table:

First, model models to build Wp_posts.php.

The copy code is as follows:

Create an IndexController.php under the controller controller

The copy code is as follows:

The above is all the contents of the article "how to configure and operate the database in zend framework". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report