Configuring Symbian and ORM Database

So, I walked with Symfony2 all morning and read the main documentation, or at least half of it. I am stuck in everything related to the database.

My simple question is: are we doing the database structure before hand or not?

The documentation says to make an Entity class and then generate the database table using the database: create in the CLI. I followed him and created a blog entity class with orm annotations.

executed the command:

php app/console doctrine:database:create

Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Applications/MAMP/htdocs/flairbagSy2/vendor/doctrine-dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php on line 36
Could not create database for connection named blog
SQLSTATE[HY000] [2002] No such file or directory

I think this has something to do with the location of the mysql socket file, but I don't know how to change the socket file path in the Symfony 2 configuration.

If anyone could indicate where I can change the path to the socket file.

I had a similar problem with CakePHP, and a simple solution was to add the port key to the db connections array:

var $default = array(
    'driver' => 'mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'root',
    'password' => 'root',
    'database' => 'cake',
    'port' => '/Applications/MAMP/tmp/mysql/mysql.sock',
);

Symfony2.

+5
3

: : create , , MySQL. , doctrine:schema:create doctrine:schema:update --force, .

, Symfony2 Doctrine . config.yml, app/config Symfony2. , config.yml:

# Doctrine Services Configuration
doctrine:
  dbal:
    default_connection: default
    connections:
      default:
        driver:   pdo_mysql
        host:     localhost
        port:     3396
        dbname:   dbname_dev
        user:     dbname_dev
        password: yourpassword
        logging:  "%kernel.debug%"

  orm:
    auto_generate_proxy_classes: "%kernel.debug%"
    default_entity_manager: default
    entity_managers:
      default:
        mappings:
          AcmeBundle: ~

dbal part, . , , , . , , , .

, orm, . , , Symfony2 . AcmeBundle , orm .

, Symfony2 , , Doctrine. , , - , - Symfony2.

, , , Symfony2 . , SQL , . , doctrine:schema:update --force . , , Symfony2 .

, , :

  • config.yml( /config ), Doctrine.
  • Symfony ( , src, -).
  • php app/console doctrine:database:create, MySQL
  • php app/console doctrine:schema:create,
  • MySQL,

.

,
Matt

+7

, Symfony2.

, app/config/config.yml, (app/config/parameters.ini).

app/config/parameters.ini database_socket:

;[parameters.ini]
database_socket   = "/var/mysql/mysql.sock"

app/config/config.yml, :

# Doctrine Configuration
doctrine:
    dbal:
        driver:   %database_driver%
        host:     %database_host%
        port:     %database_port%
        dbname:   %database_name%
        user:     %database_user%
        password: %database_password%
        unix_socket: %database_socket%
        charset:  UTF8

.

+5
+2
source

All Articles