Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KC-Database

What is it ?

Kohana Framework's DBAL (database module) as a decoupled component.

Eg ?

use KC\Database;
use KC\DB;

$db = Database::instance("default", [
  "driver" => "mysqli",
  "connection" => [
    "database" => "somedb",
    "username" => "root",
    "password" => "somepass"
  ]
]);


$result = DB::select('u.id', 'u.email', [DB::expr('group_concat(r.name)'), 'roles'])
  ->from(['users', 'u'])
      ->join(['roles_users', 'ru'])
        ->on('u.id', '=', 'ru.user_id')
      ->join(['roles', 'r'])
        ->on('r.id', '=', 'ru.role_id')
  ->groupBy('u.id')
  ->execute($db)
  ->asArray();

var_dump($result);

Outputs

array(1) {
  [0]=>
  array(3) {
    ["id"]=>
    string(2) "18"
    ["email"]=>
    string(16) "[email protected]"
    ["roles"]=>
    string(11) "login,admin"
  }
}

More Info ?

@TBD

Since the Kohana components are hard coupled to the framework, there are of course some inconsitencies. I'll fill in this section with what exactly has changed in the following weeks

About

Kohana Framework's DBAL (database module) as a decoupled component.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages