Source: http://www.grahambird.co.uk/cake/tutorials/scaffolding.php

1. Create the database table

Create the database table structure to hold your bookmarks.

CREATE TABLE bookmarks (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
name VARCHAR(255) NOT NULL,
url VARCHAR(255) NOT NULL,
created DATETIME,
modified DATETIME,
PRIMARY KEY (id) 
);

2. Create a Model file

Create a file called bookmark.php and put it in the /app/models folder. Copy and paste the code below into your file. Save it.

touch app/models/bookmark.php

gedit app/models/bookmark.php


<?php
class Bookmark extends AppModel
{
	var $name = 'Bookmark';
}
?>

3. Create a Controller file

Create a file called bookmarks_controller.php in the /app/controllers folder. Copy and paste the code below into your file. Save it.

touch app/controllers/bookmarks_controller.php

gedit app/controllers/bookmarks_controller.php

<?php
class BookmarksController extends AppController
{
	var $name = 'Bookmarks';
	var $scaffold;

}
?>

By declaring the $scaffold variable Cake automatically build our bookmarks manager for us.

4. Finished

Visit www.example.com/bookmarks. You now have a fully working bookmark management application.

  • info/tutoriel_cakephp_scaffold.txt
  • Dernière modification: 2018/07/18 09:46
  • par radeff