Skip to content

How to create the database for association

Yunai39 edited this page Mar 5, 2014 · 3 revisions

This is how you should create the entity for the database association

In a bundle in the folder entity create a new Entity named for exemple MyUserLdap <?php namespace Main\SecurityBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Yunai39\Bundle\SimpleLdapBundle\Entity\UserLdap;

/**
 * @ORM\Entity
 * @ORM\Table(name="user_ldap")
 */
class MyUserLdap extends UserLdap {

    /** @ORM\Column(type="integer") */
    protected $id;
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
}`

Then in the folder Ressource/config/doctrine of your bundle create the file MyUserLdap.orm.yml

Main\SecurityBundle\Entity\MyUserLdap:
    type: entity
    id:
        id:
            type: integer
            id: true
            generator:
                strategy: AUTO

Create the table

$ php app/console doctrine:schema:update --dump-sql
CREATE TABLE MyUserLdap (id INT AUTO_INCREMENT NOT NULL, idLdap VARCHAR(255) NOT NULL, role VARCHAR(255) NOT NULL, valid TINYINT(1) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB
$ php app/console doctrine:schema:update --force

Do not forget to create some crud to manipulate the thing and to create a user that as the superRight to edit those settings

Clone this wiki locally