dongqiuwei8667 2011-07-25 09:34
浏览 62
已采纳

在Yii中导入外部php文件

I've got some files using raw php (including config files) that's used for the automatic mailing stuff in my server.

Suppose inside this file I define a couple of constants (define(...)) and an array filled with database connection info, like user, host and so).

The website is done using Yii, so it also uses a config file.

These raw files can be placed anywhere (inside protected, outside, at the same level of index.php, whatever).

Now the problem comes that I've got a different configuration file (and different users/password for databases, and so) outside Yii, but I need to use it in some places inside Yii, too.

Is there a clear way to import these files to a controller? I've done it placing them inside extensions, but the raw functions didn't work from there.

  • 写回答

2条回答 默认 最新

  • 普通网友 2011-07-25 16:24
    关注

    The best approach would be to see if you can put your custom code into class files and put those in the components directory or similar and convert your files to classes (if they aren't already). That way you can get at your data without a lot of mixing of code which is going to be hard to maintain.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 被蓝屏搞吐了,有偿求帮解答,Ai回复直接拉黑
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
  • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角