Note that there are some explanatory texts on larger screens.

plurals
  1. POKohana database config settings for ORM
    primarykey
    data
    text
    <p>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.</p> <p>Here is my current config:</p> <p><strong>controller</strong></p> <pre><code>&lt;?php defined('SYSPATH') or die('No direct script access.'); class Controller_Welcome extends Controller { public function action_index() { $members = ORM::factory('user'); $members-&gt;where('first_name', '=', 'Peter')-&gt;find_all(); $memCount = $members-&gt;count_all(); $this-&gt;response-&gt;body('Count: ' . $memCount); } } // End Welcome </code></pre> <p><strong>Model</strong></p> <pre><code>&lt;?php defined('SYSPATH') or die('No direct access allowed.'); class Model_User extends ORM { protected $_primary_key = 'UserId'; } </code></pre> <p><strong>Config</strong> (This is located in application/config/database.php</p> <pre><code>&lt;?php defined('SYSPATH') or die('No direct access allowed.'); return array ( 'local' =&gt; array ( 'type' =&gt; 'mysql', 'connection' =&gt; array( 'hostname' =&gt; 'localhost', 'database' =&gt; 'dbname', 'username' =&gt; 'username', 'password' =&gt; '*******', 'persistent' =&gt; FALSE, ), 'table_prefix' =&gt; '', 'charset' =&gt; 'utf8', 'caching' =&gt; FALSE, 'profiling' =&gt; TRUE, ), 'remote' =&gt; array( 'type' =&gt; 'pdo', 'connection' =&gt; array( 'dsn' =&gt; 'mysql:host=localhost;dbname=kohana', 'username' =&gt; 'root', 'password' =&gt; '***', 'persistent' =&gt; FALSE, ), 'table_prefix' =&gt; '', 'charset' =&gt; 'utf8', 'caching' =&gt; FALSE, 'profiling' =&gt; TRUE, ), ); </code></pre> <p>I just want the ORM to use the <code>local</code> database. How do I do this? Right now I get the error: <code>Database_Exception [ 2 ]: mysql_connect(): Access denied for user 'www-data'@'localhost' (using password: NO)</code></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload