search

Home  >  Q&A  >  body text

Looking for symfony 1.4 propel method to operate multiple databases

Seeking symfony 1.4 propel for practical methods to operate multiple databases. Do not copy from the Internet. You must operate successfully by yourself. I hope there are detailed step-by-step instructions. Thank you so much!

漂亮男人漂亮男人2746 days ago487

reply all(2)I'll reply

  • 習慣沉默

    習慣沉默2017-05-16 16:47:23

    I always use doctrine
    If you are connecting to multiple databases
    1. Specify the connection of the table when defining the schema

    mytable:
      connection: conn1
      tableName: mytable
      columns:
        id:
          type: integer(8)
          ....

    Define database connection parameters in 2.databases.yml

    conn1:
        class: sfDoctrineDatabase
        param:
          dsn:      mysql:host=127.0.0.1;dbname=mydb;port=3306
          username: root
          password: 
          encoding: utf8 

    reply
    0
  • 高洛峰

    高洛峰2017-05-16 16:47:23

    I tested it myself and posted it first

    2. It is best to add prefixes to tables in multiple databases to avoid having the same table names and causing some models to be overwritten and lost

    3. Generate schema and yml files symfony propel:build-schema

    4. Generate form symfony propel:build-form --connection=testa symfony propel:build-form --connection=justb

    5Generate filter symfony propel:build-filters --connection=testa symfony propel:build-filters --connection=justb

    6. $c = new Criteria(); $a = APeer::doSelect($c, Propel::getConnection('testa')); $b = CPeer::doSelect($c, Propel::getConnection('justb'));

    reply
    0
  • Cancelreply