step 4: database configure for cakephp blog

step 4: database configure for cakephp blog

Make a database “cakeblog” and run the blow sql script to make a table posts and insert some demo data into it:


CREATE TABLE `posts` (
  `id` int(10) unsigned NOT NULL auto_increment,
  `title` varchar(50) default NULL,
  `body` text,
  `created` datetime default NULL,
  `modified` datetime default NULL,
  PRIMARY KEY  (`id`)
(1,'Hello world of cakephp','This is the body part of hello world of cakephp.','2010-08-20 23:49:58','2010-08-26 11:27:05'),
(2,'What is models in cakephp','Models represent data and are used in CakePHP applications for data access. A model usually represents a database table but can be used to access anything that stores data such as files, LDAP records, iCal events, or rows in a CSV file.','2010-08-20 23:49:58','2010-08-26 11:29:38'),
(3,'What is views in cakephp','Views are the V in MVC. Views are responsible for generating the specific output required for the request. Often this is in the form of HTML, XML, or JSON, but streaming files and creating PDF\'s that users can download are also responsibilities of the View Layer.','2010-08-20 23:49:58','2010-08-26 11:30:28'),
(4,'What is controllers in cakephp','A controller is used to manage the logic for a part of your application. Most commonly, controllers are used to manage the logic for a single model. For example, if you were building a site for an online bakery, you might have a RecipesController and a IngredientsController managing your recipes and their ingredients. In CakePHP, controllers are named after the model they handle, in plural form.','2010-08-26 11:31:17','2010-08-26 11:31:17');

Making database “cakeblog” and running "cakeblog.sql" in the sql editor. Like the below screen shot:


Now rename the file “database.php.default” to “database.php” found in /app/config and make the following changes to configure the database for cakeblog:


then the home page becomes like the blow screen shot i.e. CakePHP can connect to your database and database config file "database.php" is available at "/app/config/" folder.


Related Tutorial Examples

  1. 20 steps to make CakePHP Blog Project
  2. step 2: download cakephp and setup cakeblog
  3. step 3: configure security salt cakephp setup
  4. step 5: making homepage for cakephp blog
  5. step 6: template setup for cakephp blog
  6. step 7: controller for posts cakephp blog
  7. MySQL NULLIF() Function Datetime Value Example
  8. MySQL NULLIF() Function String Value Example
  9. MySQL NULL value Example using PHP
  10. MySQL Stored Procedure: Creating Table using Stored Procedure Example

No comments:

Post a Comment

leave your comments here..