In the last post I told you how to install Akelos, if you had a problem just post a comment and we'll try to help you.
Now I will try to explain what happened when you installed that "booklink" application previously.
Go to database and see what it looks like:
mysql -u root -p booklink_dev
and do
show tables;
desc books;
Now, check the file app/installers/book_installer.php (inside the booklink dir).
This is where the default data entity is defined. Akelos created it for you. This is used to create the database table that stores the books.
Change it to:
function up_1(){
$this->createTable('books',
'id,'. // the key
'title,'. // the title of the book
'description,'. // a description of the book
'author_id,'. // the author id. This is how Akelos will know how to link
'published_on' // the publication date
);
$this->createTable('authors',
'id,'. // the key
'name' // the name of the author
);
}
function down_1(){
$this->dropTables('books','authors');
}
Please note that there are naming conventions for the column names (for instance if the column name is id, then it's the primary key, and if suffix is _at then it's a datetime, etc.) To full control all your tables, check http://phplens.com/lens/adodb/docs-datadict.htm (I didn't by now)
Now, to update our application with this new model, we need to migrate (execute it from booklink directory):
php script/migrate book install
Now you can go to the database
mysql -u root -p booklink_dev
and do
show tables;
desc books;
desc authors;
Now we need to create the scaffold for both entities: books and authors.
To do so, we will execute:
php script/generate scaffold book
and
php script/generate scaffold author
If you get this error:
There where collisions when attempting to generate the scaffold.
Please add force=true to the argument list in order to overwrite existing files.
Then do:
php script/generate scaffold book --force
and
php script/generate scaffold author --force
(the --force will akelos to rewrite some files)
Now check your application. Cool isn't it?
quinta-feira, 7 de agosto de 2008
Akelos PHP Framework How to create an application
Etiquetas:
akelos,
akelos development,
akelos example,
php framework,
web development
Subscrever:
Enviar feedback (Atom)
Sem comentários:
Enviar um comentário