Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reproduced problem DDC-2844 #8

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/AppKernel.php
Expand Up @@ -16,6 +16,8 @@ public function registerBundles()
new Symfony\Bundle\AsseticBundle\AsseticBundle(), new Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(), new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle(),
new Hautelook\AliceBundle\HautelookAliceBundle(),
); );


if (in_array($this->getEnvironment(), array('dev', 'test'))) { if (in_array($this->getEnvironment(), array('dev', 'test'))) {
Expand Down
2 changes: 0 additions & 2 deletions app/SymfonyRequirements.php
Expand Up @@ -648,8 +648,6 @@ class_exists('Locale'),
|| ||
(extension_loaded('apc') && ini_get('apc.enabled')) (extension_loaded('apc') && ini_get('apc.enabled'))
|| ||
(extension_loaded('Zend Optimizer+') && ini_get('zend_optimizerplus.enable'))
||
(extension_loaded('Zend OPcache') && ini_get('opcache.enable')) (extension_loaded('Zend OPcache') && ini_get('opcache.enable'))
|| ||
(extension_loaded('xcache') && ini_get('xcache.cacher')) (extension_loaded('xcache') && ini_get('xcache.cacher'))
Expand Down
2 changes: 2 additions & 0 deletions app/config/config.yml
Expand Up @@ -65,3 +65,5 @@ swiftmailer:
username: "%mailer_user%" username: "%mailer_user%"
password: "%mailer_password%" password: "%mailer_password%"
spool: { type: memory } spool: { type: memory }

hautelook_alice: ~
3 changes: 2 additions & 1 deletion composer.json
Expand Up @@ -18,7 +18,8 @@
"sensio/distribution-bundle": "~2.3", "sensio/distribution-bundle": "~2.3",
"sensio/framework-extra-bundle": "~2.3", "sensio/framework-extra-bundle": "~2.3",
"sensio/generator-bundle": "~2.3", "sensio/generator-bundle": "~2.3",
"incenteev/composer-parameter-handler": "~2.0" "incenteev/composer-parameter-handler": "~2.0",
"hautelook/alice-bundle": "dev-master"
}, },
"scripts": { "scripts": {
"post-install-cmd": [ "post-install-cmd": [
Expand Down
42 changes: 42 additions & 0 deletions src/Acme/DemoBundle/Controller/DemoController.php
Expand Up @@ -2,6 +2,8 @@


namespace Acme\DemoBundle\Controller; namespace Acme\DemoBundle\Controller;


use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\EntityRepository;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
Expand All @@ -19,6 +21,46 @@ class DemoController extends Controller
*/ */
public function indexAction() public function indexAction()
{ {
/** @var \Doctrine\ORM\EntityRepository $userRepository */
$userRepository = $this->getDoctrine()->getRepository('AcmeDemoBundle:User');
$date = '2013-12-02';
$dateFrom = new \DateTime ($date);
$dateTo = (new \DateTime ($date))->add(new \DateInterval('P1D'));

// OK
$criteria = new Criteria();
$criteria
->where($criteria->expr()->gte('signedIn', $dateFrom))
->andWhere($criteria->expr()->lt('signedIn', $dateTo))
;
//var_dump($userRepository->matching($criteria));

// NOT OK - Doctrine\ORM\Query\QueryException "Invalid parameter number: number of bound variables does not match number of tokens"
$criteria = new Criteria();
$criteria
->where($criteria->expr()->gte('user.signedIn', $dateFrom))
->andWhere($criteria->expr()->lt('user.signedIn', $dateTo))
->orWhere ($criteria->expr()->eq ('user.signedIn', true))
;
var_dump($userRepository->createQueryBuilder('user')
->addCriteria($criteria)
->getQuery()
->getResult()
)
;die();

// NOT OK - Doctrine\ORM\Query\QueryException "Invalid parameter number: number of bound variables does not match number of tokens"
$criteria
->where($criteria->expr()->eq('user.active', true))
->andWhere($criteria->expr()->eq('user.active', true))
//->orWhere ($criteria->expr ()->eq ('user.active', true))
;
var_dump($userRepository->createQueryBuilder('user')
->addCriteria($criteria)
->getQuery()
->getResult()
);

return array(); return array();
} }


Expand Down
19 changes: 19 additions & 0 deletions src/Acme/DemoBundle/DataFixtures/ORM/TestLoader.php
@@ -0,0 +1,19 @@
<?php

namespace Acme\DemoBundle\DataFixtures\ORM;

use Hautelook\AliceBundle\Alice\DataFixtureLoader;
use Nelmio\Alice\Fixtures;

class TestLoader extends DataFixtureLoader
{
/**
* {@inheritDoc}
*/
protected function getFixtures()
{
return array(
__DIR__ . '/users.yml',
);
}
}
3 changes: 3 additions & 0 deletions src/Acme/DemoBundle/DataFixtures/ORM/users.yml
@@ -0,0 +1,3 @@
Acme\DemoBundle\Entity\User:
user{1..50}:
signedIn: <dateTimeBetween('-2 weeks', 'now')>
33 changes: 33 additions & 0 deletions src/Acme/DemoBundle/Entity/User.php
@@ -0,0 +1,33 @@
<?php

namespace Acme\DemoBundle\Entity;

class User
{
protected $id;
protected $signedIn;

/**
* @return mixed
*/
public function getId()
{
return $this->id;
}

/**
* @return mixed
*/
public function getSignedIn()
{
return $this->signedIn;
}

/**
* @param mixed $signedIn
*/
public function setSignedIn($signedIn)
{
$this->signedIn = $signedIn;
}
}
18 changes: 18 additions & 0 deletions src/Acme/DemoBundle/Resources/config/doctrine/User.orm.yml
@@ -0,0 +1,18 @@
Acme\DemoBundle\Entity\User:
type: entity
#repositoryClass: Doctrine\Tests\ORM\Mapping\UserRepository
table: user
id:
id:
type: integer
generator:
strategy: AUTO
fields:
signedIn:
type: datetime
# oneToOne:
# address:
# targetEntity: Address
# joinColumn:
# name: address_id
# referencedColumnName: id