Looking for symfony 1.4 propel method to operate multiple databases
漂亮男人
漂亮男人 2017-05-16 16:45:23
0
2
465

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!

漂亮男人
漂亮男人

reply all(2)
習慣沉默

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 
小葫芦

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'));

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!