How to choose the database configuration that ORM should use? The docs mention how to configure and select it using the clean database method. Not when using ORM.
Here is my current configuration:
controller
<?php defined('SYSPATH') or die('No direct script access.'); class Controller_Welcome extends Controller { public function action_index() { $members = ORM::factory('user'); $members->where('first_name', '=', 'Peter')->find_all(); $memCount = $members->count_all(); $this->response->body('Count: ' . $memCount); } }
Model
<?php defined('SYSPATH') or die('No direct access allowed.'); class Model_User extends ORM { protected $_primary_key = 'UserId'; }
Configuration (this is in the app /config/database.php
<?php defined('SYSPATH') or die('No direct access allowed.'); return array ( 'local' => array ( 'type' => 'mysql', 'connection' => array( 'hostname' => 'localhost', 'database' => 'dbname', 'username' => 'username', 'password' => '*******', 'persistent' => FALSE, ), 'table_prefix' => '', 'charset' => 'utf8', 'caching' => FALSE, 'profiling' => TRUE, ), 'remote' => array( 'type' => 'pdo', 'connection' => array( 'dsn' => 'mysql:host=localhost;dbname=kohana', 'username' => 'root', 'password' => '***', 'persistent' => FALSE, ), 'table_prefix' => '', 'charset' => 'utf8', 'caching' => FALSE, 'profiling' => TRUE, ), );
I just want ORM to use the local
database. How can I do it? Now I get the error message: Database_Exception [ 2 ]: mysql_connect(): Access denied for user 'www-data'@'localhost' (using password: NO)