Laravel / Eloquent : change connection and get all -


i have 2 database connections defined:

  • sqlite: connection specific sqlite db,
  • mysql: classic mysql db.

and following model class:

class boperson extends \illuminate\database\eloquent\model {   protected $table = 'persons';   protected $connection = 'mysql';   public $timestamps = false; } 

this works:

$persons = boperson::all(); 

but doesn't work:

$persons = boperson::on('sqlite')->all(); 

how switch default 'mysql' connection 1 named 'sqlite'?

all() static function.

in case, use get():

$persons = boperson::on('sqlite')->get();

source: http://laravel.com/docs/4.2/eloquent#basic-usage


Comments

Popular posts from this blog

IF statement in MySQL trigger -

c++ - What does MSC in "// appease MSC" comments mean? -

javascript - Blogger related post gadget image Resize s72-c [ Need Expert Help ] -