doctrine
symfony2 doctrine allow null values?
I’ve just been looking for the solution, and wasn’t happy with the accepted solution. [Edit: though I now know it’s because I was using annotation]. The way I’ve found that works for me is setting nullable: /** * @ORM\Column(type=”varchar”, nullable=true) */ private $totaltime = null;
How to specify null value as filter in a Doctrine query?
I use doctrine with symfony, and this is how I do: where(‘a.vertical_id is NULL’);
Why doesn’t MySQL support millisecond / microsecond precision?
For information for the next readers, this bug has finally be corrected in version 5.6.4: “MySQL now supports fractional seconds for TIME, DATETIME, and TIMESTAMP values, with up to microsecond precision.”
Complex WHERE clauses using the PHP Doctrine ORM
From my experience, each complex where function is grouped within parenthesis (I’m using Doctrine 1.2.1). $q->where(‘name = ?’, ‘ABC’) ->andWhere(‘category1 = ? OR category2 = ? OR category3 = ?’, array(‘X’, ‘X’, ‘X’)) ->andWhere(‘price < ?’, 10) produces the following SQL: WHERE name=”ABC” AND (category1 = ‘X’ OR category2 = ‘X’ OR category3 = ‘X’) … Read more
Using Raw SQL with Doctrine
$q = Doctrine_Manager::getInstance()->getCurrentConnection(); $result = $q->execute(” — RAW SQL HERE — “); See the Doctrine API documentation for different execution methods.
pass array of conditions to doctrine expr()->orx() method
I hope so, then I found this : $conditions = array(‘e.type = x’, ‘e.type = Y’, ‘e.type = N’); $orX = $qb->expr()->orX(); foreach ($conditions as $condition) { $orX->add($condition); } $qb->add(‘where’, $orX); Using @meze suggestion, you can simplify the code and replace the foreach statement with: $orX->addMultiple($conditions);
Symfony2 $user->setPassword() updates password as plain text [DataFixtures + FOSUserBundle]
Since you are using FOSUserBundle, you can use UserManager to do this. I would use this code (assuming you have $this->container set): public function load(ObjectManager $manager) { $userManager = $this->container->get(‘fos_user.user_manager’); $userAdmin = $userManager->createUser(); $userAdmin->setUsername(‘System’); $userAdmin->setEmail(‘system@example.com’); $userAdmin->setPlainPassword(‘test’); $userAdmin->setEnabled(true); $userManager->updateUser($userAdmin, true); }