Connection to MySQL database from Zend framework 1.12.3 in Netbeans

First create in MySQL server country_db database with only one table country. I do it by means of phpMyAdmin.
You write in empty field name of database and select utf8_unicode_ci as Collation and click Create button.

On the list of databases click on country_db link.
In Name field write name of table: country and in Number of column write 2.

Click on Go button.
Write name of column for this table: country, continent and id(as primary key with auto increment.
Set data in the table.
This is list of countries in table country.
Then create project country.
Create in Netbeans project country. Choose from menu File->New Project.
Select PHP from Categories part and PHP Application from Projects part of window.
Click Next button. In Projects Name field write country. Click Next button.
In Project URL field add in path public word.
Click Next button.
Choose Zend PHP Web Framework from the list. Click Finish button.
In structureof tree You see country project’s nodes.
First You must configure connection to databse so open application.ini file from application/configs node and write these lines on the end file:

    resources.db.adapter = "pdo_mysql"
    resources.db.params.dbname = "country_db"
    resources.db.params.host = "localhost"
    resources.db.params.username = "root"
    resources.db.params.password = "dorota"
    resources.db.params.charset = "utf8"

First line it is only information in this file that it is part about MySQL configuration.
Another are params for database.

In this moment You may create layout for Your application. Right click on the project name and select from pop-up menu Zend->Zend Command.
In Filter field write enable layout and click Run button.
In Projects window double click on layout.phtml file.
In the file paste code:

 
      
    
    Countries
    
    
       
    
    

And save file.
There You must generate class which will be connect to database. In Run Command window in Filter field write:
create db-tab
and in Parameters field write:
Country country
where Country is class’s name and country is table’s name.
Click Run command.
In model node You see DbTable node with Country.php file.
This file is class for connect to country table in database.
Model is used to logical operation, example for database operations.
Double click on IndexController.php file and write this code in indexAction method:
$c=new Application_Model_DbTable_Country();
$this->view->country=$c->fetchAll();

Variable $c contain object class implemented in Country.php file.
For this object is executed method fetchAll getting all data from table country.
This data we set in view for controller index. This view is index view. So open file view/script/index/index.phtml.
Delete from this file content and write this code:

Countries



   
 
                            
               

               

           

       
country continent


Here You run Your project.