Using multiple database on same CodeIgniter 2.x ap

2019-05-10 16:06发布

I am working on a small web application. In my application I follow the following approach.

Small overview of system

  1. The Application will be hosted on the server for example (www.example.com )
  2. Clients such as Microsoft, Cocacola, IBM.... etc will sign up. And the clients will access the application by using url like this ( www.example.com/ibm )
  3. Each client will have separate database to store their data.
  4. If the employees of the client want to login into the system then the url pattern should be like this :

    (www.example.com/ibm/user/login)
    ibm - is the client
    user - is controller
    login - is method of user controller

How to achieve this?

1条回答
该账号已被封号
2楼-- · 2019-05-10 16:22

Thanks Sundar for your advice. We can achieve this just by little hack in core of codeigniter.

  1. Open system/core/router.php in your text editor.
  2. Go to Line number 264 .... function _validate_request($segments)
  3. Replace $segments[0] with $segments[1] OR
  4. Add this code at line 270

    $x=$segments; $a=1; for($i=0;$i<(count($segments)-1); $i++) { $segments[$i]=$x[$a]; $a++; }

查看更多
登录 后发表回答