laravel - Edit active database on the fly -
so i'm working on little web application in can manage database.
now can use following function retrieve databases
db::select('show databases')
but want able tables each of databases , more databases, figured if working wouldn't problem.
normally you'd have different database in config, since want application work "any" database , make sure don't have manually add databases etc since that's kind of work want web app done me.
i've tried tricking around bit without success example.
db:select('use dbname; show tables'); db::select('select dbname(); show tables');
obviously didn't work, there "proper" solution this? thought editing .env variable on fly might've been option, can't seem find "legit" way either.
you don't need this.
i thought editing .env variable on fly might've been option, can't seem find "legit" way either.
what need this
db::purge('mysql');//imp config::set('database.connections.mysql.host', $host); config::set('database.connections.mysql.database', $database); config::set('database.connections.mysql.username', $username); config::set('database.connections.mysql.password', $password);
you need figure out way values $host
, $database
, $username
, , $password
dynamically.
one way have database stores these values , point default database connection (say mysql
in config/database.php
) it. read values on fly , set connections accordingly.
Comments
Post a Comment