[eluser]Adam Liszkai[/eluser]
If you have multiple databases then you must fill out the
/application/config/database.php
Code:
$config['hostname'] = "localhost";
$config['username'] = " YOUR USERNAME FOR DATABASES ";
$config['password'] = " YOUR PASSWORD FOR DATABASES ";
$config['database'] = " YOUR DEFAULT DATABASE NAME ";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = ""; // if you have prefix put it there
Then to access multiple database:
Code:
<?
/**
* @name: Kanban model
* @author: 'Adam Liszkai' <[email protected]>
* @return: Kanban model echo message :D
*/
class Kanban_model extends CI_Model
{
public function __construct()
{
parent::__construct();
// Load html helper
$this->load->helper('html');
/*
* Connect to the 'kanban' database, if is not the
* default in the /application/config/database.php
*
*/
$kanban_db = $this->load->database('kanban', TRUE);
}
/*
* @name: Index function
* @author: 'Adam Liszkai' <[email protected]>
* @return: Kanban model echo message :D
*/
public function index()
{
echo(heading('KANBAAAAAAN! :D', 3)."\n\r");
$query = $kanban_db->get('kanban_table');
foreach ($query->result() as $row)
{
echo($row->kanban_cell.br(1)."\n\r");
}
// @TODO: Some more code! :D
}
}
?>
But if you have just one database, then i suggest fill out the database informations in /application/config/database.php
Code:
$config['hostname'] = "localhost";
$config['username'] = " YOUR USERNAME FOR DATABASE ";
$config['password'] = " YOUR PASSWORD FOR DATABASE ";
$config['database'] = " YOUR DATABASE NAME ";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = ""; // if you have prefix put it there
then use
Code:
<?
/**
* @name: Kanban model
* @author: 'Adam Liszkai' <[email protected]>
* @return: Kanban model echo message :D
*/
class Kanban_model extends CI_Model
{
public function __construct()
{
parent::__construct();
// Load html helper
$this->load->helper('html');
// Load the database
$this->load->database();
}
/*
* @name: Index function
* @author: 'Adam Liszkai' <[email protected]>
* @return: Kanban model echo message :D
*/
public function index()
{
echo(heading('KANBAAAAAAN! :D', 3)."\n\r");
$query = $this->db->get('kanban_table');
foreach ($query->result() as $row)
{
echo($row->kanban_cell.br(1)."\n\r");
}
// @TODO: Some more code! :D
}
}
?>
this modell
More examples:
http://ellislab.com/codeigniter/user-gui...index.html