![Phalcon Tutorial](/phalcon/images/phalcon-mini-logo.jpg)
- Phalcon Tutorial
- Phalcon - Home
- Phalcon - Overview
- Phalcon - Environmental Setup
- Phalcon - Application Structure
- Phalcon - Functionality
- Phalcon - Configuration
- Phalcon - Controllers
- Phalcon - Models
- Phalcon - Views
- Phalcon - Routing
- Phalcon - Database Connectivity
- Phalcon - Switching Databases
- Phalcon - Scaffolding Application
- Phalcon - Query Language
- Phalcon - Database Migration
- Phalcon - Cookie Management
- Phalcon - Session Management
- Phalcon - Multi-Lingual Support
- Phalcon - Asset Management
- Phalcon - Working with Forms
- Phalcon - Object Document Mapper
- Phalcon - Security Features
- Phalcon Useful Resources
- Phalcon - Quick Guide
- Phalcon - Useful Resources
- Phalcon - Discussion
Phalcon - Database Connectivity
In this chapter, we will discuss the database connectivity related to Phalcon.
Creation of Database and Design
We will focus on creating a database for blogs which maintains posts along with the categories as per the entries of users.
Database Name: blog-tutorial
Query used for creating the database −
drop database blog-tutorial (if exists) create database blog-tutorial
After creation of the database, the database will be listed as shown in the following screenshot.
![Database](/phalcon/images/database.jpg)
Phalcon uses commands for creation of models, controllers, and even projects. Let’s see how it works.
Step 1 − Create a project named blog-tutorial.
![Project Name](/phalcon/images/project_name.jpg)
Step 2 − Configure the web application that connects to the database which we created for managing blogs.
<?php return new \Phalcon\Config (array ( 'database' => array ( 'adapter' => 'Mysql', 'host' => 'localhost', 'username' => 'root', // 'dbname' => 'blog_tutorial', 'password' => '', 'name' => 'blog_tutorial', ), 'application' => array ( 'controllersDir' => __DIR__ . '/../../app/controllers/', 'modelsDir' => __DIR__ . '/../../app/models/', 'viewsDir' => __DIR__ . '/../../app/views/', 'baseUri' => '/blog-tutorial/', ) ));
Advertisements