Notes on Java, Solaris, PHP, LDAP…

November 17, 2007

MySQL, CakePHP tips

Filed under: Uncategorized — negev @ 5:26 pm
Tags: , ,

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%';
Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: