Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6870223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:39:26+00:00 2026-05-27T03:39:26+00:00

How do I select which database config my ORM should use? The docs only

  • 0

How do I select which database config my ORM should use? The docs only mentions how to setup the config and select it when using the pure database method. Not when using an ORM.

Here is my current config:

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

} // End Welcome

Model

<?php defined('SYSPATH') or die('No direct access allowed.');

class Model_User extends ORM
{   
    protected $_primary_key = 'UserId';
}

Config (This is located in application/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 the ORM to use the local database. How do I do this? Right now I get the error: Database_Exception [ 2 ]: mysql_connect(): Access denied for user 'www-data'@'localhost' (using password: NO)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:39:27+00:00Added an answer on May 27, 2026 at 3:39 am

    Like Kowser said, for Database::instance() to return a connection using the ‘local’ database group use Database::$default = ‘local’;

    If you want to let a class use a specific database group that is not Database::$default.
    Then in your class definition set $_db_group to the database config group like so:

    <?php defined('SYSPATH') or die('No direct access allowed.');
    
    class Model_User extends ORM
    {
        protected $_db_group = 'local';
        protected $_primary_key = 'UserId';
    }
    

    This way you can set Database::$default to ‘remote’ and only objects of that class will use the ‘local’ connection.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataTable which I select from database (Well, these data cross several
I have a select list which is being populated using the values from a
I have a content based, read-only iPhone app. Users can select favorite topics, which
I have a jQuery select which works in most browsers axcept IE. The code
Is there a way to select which TestMethods you want to execute in Visual
Has anyone tried to dynamically select which properties they want to write to an
I have a datagridview where the users can select which subset of columns to
SQL query which select the record from three tables and there is no relation
I have a select box which has more than 200 items. Below the select
I have a SQL SELECT query which has a LIKE clause containing an underscore,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.