./symfony doctrine:generate-module frontend job JobeetJob
Last active
December 19, 2015 01:19
-
-
Save mmiliaus/5875347 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// find record by ID | |
$article = Doctrine_Core::getTable('Article')->find(123); | |
// set multi attributes in one go | |
$article->fromArray(array( | |
'Title' => 'My first article', | |
'Content' => 'This is my very first article.\n Hope you enjoy it!', | |
)); | |
// Query interface | |
// execute() - fetch all records | |
// fetchOne() - to fetch just a single record | |
$q = Doctrine_Core::getTable('Comment') | |
->createQuery('c') | |
->where('c.author = ?', 'Steve') | |
->leftJoin('c.Article a') | |
->andWhere('a.content LIKE ?', '%enjoy%') | |
->orderBy('c.created_at ASC'); | |
$comments = $q->execute(); | |
// raw SQL | |
$connection = Doctrine_Manager::connection(); | |
$query = 'SELECT MAX(created_at) AS max FROM blog_article'; | |
$statement = $connection->execute($query); | |
$statement->execute(); | |
$resultset = $statement->fetch(PDO::FETCH_OBJ); | |
$max = $resultset->max; | |
// Join with table, that has no Relation | |
$q = new Doctrine_RawSql(); | |
$categories = $q | |
->select('{c.*}') | |
->from(' | |
category c | |
left join temp_user_categories uc ON uc.category_id = c.id | |
') | |
->addComponent('c', 'Category c') | |
->where('c.type = ?', self::CATEGORY_TYPE_DB) | |
->orderBy('uc.is_active DESC, c.position') | |
->execute(); |
- Update config/doctrine/schema.yml
./symfony doctrine:generate-migrations-diff
- only a migration for the new change will get created./symfony doctrine:migrate
- migrate all the pending migrations
./symfony doctrine:migrate --down
- migrate one migration down./symfony doctrine:migrate N-22
- migrate to version "22"
./symfony doctrine:build --all-classes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment