在同一CodeIgniter 2.x应用程序上使用多个数据库并出现URI路由问题 [英] Using multiple database on same CodeIgniter 2.x application and issue with URI Routing

查看:47
本文介绍了在同一CodeIgniter 2.x应用程序上使用多个数据库并出现URI路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个小型Web应用程序。在我的应用程序中,我采用以下方法。

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

系统小概况


  1. 该应用程序将托管在服务器上,例如(www.example.com)

  2. 诸如Microsoft,Cocacola,IBM等客户端将注册。客户端将使用这样的URL(www.example.com/ibm)来访问应用程序。

  3. 每个客户端将具有单独的数据库来存储其数据。

  4. 如果客户端的员工希望登录系统,则网址格式应为:

  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 /用户/登录)

ibm-是客户端

用户-是控制器

登录-是用户控制器的方法

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

如何实现?

推荐答案

感谢Sundar的建议。
我们可以通过在codeigniter的核心中进行一点改动来实现此目的。

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


  1. 在您的文本中打开system / core / router.php编辑器。

  2. 转到行号264 ....函数_validate_request($ segments)

  3. 用$ segments [1]替换$ segments [0]。 ]

  4. 在第270行添加此代码

  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 ++;
}

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

这篇关于在同一CodeIgniter 2.x应用程序上使用多个数据库并出现URI路由问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆