Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


Controller code (php)

1
2
3
4
5
6
7
8
9
10
# Get group with ID 10 and user with ID 36:

$group = $om->getRepository( 'AcmeGroupBundle:Group' )->find( 10 );
$user  = $om->getRepository( 'AcmeUserBundle:User' )->find( 36 );   # User entity implements Acme\GroupBundle\Model\UserInterface

# Add a user to group:

$group->addUser( $user );
$om->flush();

Error (plain_text)

1
2
3
4
An exception occurred while executing 'INSERT INTO acme_group_user (group_id, user_id) VALUES (?, ?)' with params {"1":10,"2":36,"3":10,"4":36}:

SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens

Resolving target entity in config.yml (yaml)

1
2
3
4
5
6
7
8

doctrine:
    # ...
    orm:
        # ...
        resolve_target_entities:
            Acme\GroupBundle\Model\UserInterface: Acme\UserBundle\Entity\User

Mapping of Group (yaml)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Acme\GroupBundle\Entity\Group:
    type: entity
    table: acme_group
    id:
        id:
            type: integer
            generator: { strategy: AUTO }
    manyToMany:
        users:
            targetEntity: Acme\GroupBundle\Model\UserInterface
            joinTable:
                name: acme_group_user
                joinColumns:
                    group_id:
                        referencedColumnName: id
                inverseJoinColumns:
                    user_id:
                        referencedColumnName: id

Group entity (php)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
namespace Acme\GroupBundle\Entity;

use Acme\GroupBundle\Model\UserInterface;
use Doctrine\Common\Collections\ArrayCollection;

class Group
{
    /**
     * @var mixed
     */
    protected $id;
    
    /**
     * @var string
     */
    protected $title;

    /**
     * @var Collection
     */
    protected $users;
    
    /**
     * Constructor
     */
    public function __construct()
    {
        $this->users = new ArrayCollection();
    }

    /**
     * 
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }
    
    /**
     * @return string
     */
    public function getTitle()
    {
        return $this->title;
    }
    
    /**
     * @param string $title
     */
    public function setTitle( $title )
    {
        $this->title = $title;
    }

    /**
     * @return Collection
     */
    public function getUsers()
    {
        return $this->users;   
    }

    /**
     * @param \Acme\GroupBundle\Model\UserInterface $user
     */
    public function addUser( UserInterface $user )
    {
        $this->users[] = $user;
    }

    /**
     * @param \Acme\GroupBundle\Model\UserInterface $user
     */
    public function removeUser( UserInterface $user )
    {
        $this->users->removeElement( $user );
    }
}

Mapped superclass (php)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
namespace Acme\GroupBundle\Model;

/**
 * Implemented by the application's User entity
 */
interface UserInterface
{
    /**
     * @var mixed
     */
    public function getId();
    
    /**
     * @var string
     */
    public function getUsername();
}

Extending entity User (php)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
namespace Acme\UserBundle\Entity;

use Acme\GroupBundle\Model\UserInterface as AcmeUserInterface;
use Doctrine\ORM\Mapping as ORM;
use Doctrine\Common\Collections\ArrayCollection;

/**
 * @ORM\Entity
 * @ORM\Table(name="acme_user")
 */
class User implements AcmeUserInterface
{
    /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
    
    /**
     * @ORM\Column(type="string")
     */
    protected $username;
    
    /**
     *
     */
    public function getId()
    {
        return $this->id;
    }
    
    /**
     *
     */
    public function getUsername()
    {
        return $this->username;
    }
}

Full stacktrace (plain_text)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
                                                                                                                                                           
  [Doctrine\DBAL\DBALException]                                                                                                                             
  An exception occurred while executing 'INSERT INTO acme_group_user (group_id, user_id) VALUES (?, ?)' with params {"1":7,"2":7,"3":7,"4":7}:  
                                                                                                                                                            
  SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens                                                      


Exception trace:
 () at /path/to/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php:47
 Doctrine\DBAL\DBALException::driverExceptionDuringQuery() at /path/to/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:793
 Doctrine\DBAL\Connection->executeUpdate() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php:146
 Doctrine\ORM\Persisters\AbstractCollectionPersister->insertRows() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php:124
 Doctrine\ORM\Persisters\AbstractCollectionPersister->update() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:332
 Doctrine\ORM\UnitOfWork->commit() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:355
 Doctrine\ORM\EntityManager->flush() at /path/to/project/vendor/src/Acme/UserBundle/DataFixtures/ORM/LoadGroups.php:42
 Acme\UserBundle\DataFixtures\ORM\LoadGroups->load() at /path/to/project/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/AbstractExecutor.php:120
 Doctrine\Common\DataFixtures\Executor\AbstractExecutor->load() at /path/to/project/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/ORMExecutor.php:83
 Doctrine\Common\DataFixtures\Executor\{closure}() at n/a:n/a
 call_user_func() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:223
 Doctrine\ORM\EntityManager->transactional() at /path/to/project/vendor/app/cache/dev/jms_diextra/doctrine/EntityManager_50a242b170ab1.php:31
 EntityManager50a242b170ab1_546a8d27f194334ee012bfe64f629947b07e4919\__CG__\Doctrine\ORM\EntityManager->transactional() at /path/to/project/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/ORMExecutor.php:85
 Doctrine\Common\DataFixtures\Executor\ORMExecutor->execute() at /path/to/project/vendor/doctrine/doctrine-fixtures-bundle/Doctrine/Bundle/FixturesBundle/Command/LoadDataFixturesDoctrineCommand.php:106
 Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand->execute() at /path/to/project/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:238
 Symfony\Component\Console\Command\Command->run() at /path/to/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:193
 Symfony\Component\Console\Application->doRun() at /path/to/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:78
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /path/to/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:106
 Symfony\Component\Console\Application->run() at /path/to/project/vendor/app/console:22

                                             
  [PDOException]                                                                                        
  SQLSTATE[HY093]: Invalid parameter number: number of bound variables does not match number of tokens  


Exception trace:
 () at /path/to/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:786
 PDOStatement->execute() at /path/to/project/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php:786
 Doctrine\DBAL\Connection->executeUpdate() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php:146
 Doctrine\ORM\Persisters\AbstractCollectionPersister->insertRows() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/AbstractCollectionPersister.php:124
 Doctrine\ORM\Persisters\AbstractCollectionPersister->update() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:332
 Doctrine\ORM\UnitOfWork->commit() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:355
 Doctrine\ORM\EntityManager->flush() at /path/to/project/vendor/src/Acme/UserBundle/DataFixtures/ORM/LoadGroups.php:42
 Acme\UserBundle\DataFixtures\ORM\LoadGroups->load() at /path/to/project/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/AbstractExecutor.php:120
 Doctrine\Common\DataFixtures\Executor\AbstractExecutor->load() at /path/to/project/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/ORMExecutor.php:83
 Doctrine\Common\DataFixtures\Executor\{closure}() at n/a:n/a
 call_user_func() at /path/to/project/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:223
 Doctrine\ORM\EntityManager->transactional() at /path/to/project/vendor/app/cache/dev/jms_diextra/doctrine/EntityManager_50a242b170ab1.php:31
 EntityManager50a242b170ab1_546a8d27f194334ee012bfe64f629947b07e4919\__CG__\Doctrine\ORM\EntityManager->transactional() at /path/to/project/vendor/doctrine/data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/ORMExecutor.php:85
 Doctrine\Common\DataFixtures\Executor\ORMExecutor->execute() at /path/to/project/vendor/doctrine/doctrine-fixtures-bundle/Doctrine/Bundle/FixturesBundle/Command/LoadDataFixturesDoctrineCommand.php:106
 Doctrine\Bundle\FixturesBundle\Command\LoadDataFixturesDoctrineCommand->execute() at /path/to/project/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:238
 Symfony\Component\Console\Command\Command->run() at /path/to/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:193
 Symfony\Component\Console\Application->doRun() at /path/to/project/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:78
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /path/to/project/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:106
 Symfony\Component\Console\Application->run() at /path/to/project/vendor/app/console:22