28 Feb 07
Mutliple databases and PHP frameworks
- Code Igniter (OpenWorld)
— in a controller: $this->load->model( ‘Officemodel’, ”, $this->config->item(‘my_db_profile’) );
— in application/config/autoload.php -> add a new config file for the other DB, e.g. application/config/database_2nd.php:
$autoload['config']= array( whatever-was-there, ‘database_2nd’ )
- CakePHP
– have several DB ‘profiles’ in app/config/database.php
– in model class: var $useDbConfig = ‘my_db_profile’;
CakePHP
MySQL 4.1.13-standard: do not have DB user and DB name same, otherwise it used to cause problems.
— however, same DB user and database name worked on another instance of MySQL 4.1.13-standard
MySQL -copying a value from one DB or table to another:
use main_db;
UPDATE cities SET name=(SELECT name FROM old_main_db.cities WHERE id=337) WHERE id=337;
CakePHP multi-DB application:
Have following set in the model(s):
var $useDbConfig = ‘test’;
Unicode in MySQL:
SET NAMES 'charset_name' COLLATE 'collation_name'
or
SET NAMES ‘utf8′;
- the above commands set several variables, list them by
SHOW VARIABLES LIKE 'c%';