在同一CodeIgniter 2.x应用程序上使用多个数据库并出现URI路由问题

编程入门 行业动态 更新时间:2024-10-28 18:29:33
本文介绍了在同一CodeIgniter 2.x应用程序上使用多个数据库并出现URI路由问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

系统小概况

  • 该应用程序将托管在服务器上,例如(www.example)
  • 诸如Microsoft,Cocacola,IBM等客户端将注册。客户端将使用这样的URL(www.example/ibm)来访问应用程序。
  • 每个客户端将具有单独的数据库来存储其数据。
  • 如果客户端的员工希望登录系统,则网址格式应为:

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

    (www.example/ ibm /用户/登录) ibm-是客户端 用户-是控制器 登录-是用户控制器的方法

    (www.example/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.

  • 在您的文本中打开system / core / router.php编辑器。
  • 转到行号264 ....函数_validate_request($ segments)
  • 用$ segments [1]替换$ segments [0]。 ] 或
  • 在第270行添加此代码

  • Open system/core/router.php in your text editor.
  • Go to Line number 264 .... function _validate_request($segments)
  • Replace $segments[0] with $segments[1] OR
  • 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路由问题

    本文发布于:2023-10-30 03:12:41,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1541596.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:多个   路由   应用程序   数据库   在同一

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!