How to set connection between Symfony Framework with Doctrine and Mysql? It’s easy brother. Beforehand, I have difficulties in this connection. I wish you didn’t experience it’s also. So, let’s try my way.
Four easy step to make connection Doctrine and Mysql.
First Step!
I suggest you to using PHP version 5.2 (or higher) for Symfony 1.2. Check your PDO extension in php.ini. Open your file php.ini and search extension php_pdo.dll and php_mysql_pdo.dll, and activate it by removing this “;”. If there is no one PDO, you can add this extension to the end of list extension.
Second Step!
Now you must edit and setting database connection in your Symfony. Open file sf_sanbox/config/database.yml, input your Mysql username/root and password, and your database.
Here is my connection:
Or, you can set your connection by another way, with command line.
symfony configure:database --name=doctrine --class=sfDoctrineDatabase "mysql:host=localhost;dbname=dbname" username yourpassword
Don’t forget to delete all setting Propel on database.yml
Third Step!
Next step, I can explain about using Doctrine in Symfony. Create database – table – schema – model. Or the other way, create schema – database – model, with symfony doctrine:build-all.
After that, check your table model in lib/model/doctrine.
for create schema from database :
symfony doctrine:build-shcema
for create model from schema :
symfony doctrine:build-modelfor create database/table and model from schema
symfony doctrine:build-all
Fourth Step!
Finally it’s done. You can create query for your application with doctrine ORM. It’s very simple and powerfull.
OMG! it's a great article, Share Oh!
0 komentar:
Post a Comment