如何在Codeigniter的模型中包含文件? [英] how to include a file inside a model in codeigniter?

查看:111
本文介绍了如何在Codeigniter的模型中包含文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Codeigniter的新手,也许我的问题有点愚蠢,但是..我不明白如何在模型中包含文件。

I’m new to codeigniter and maybe my question is a bit stupid but..I cant understand how I can include a file inside a model.

内部del模型文件夹中有一个名为include的子文件夹,并且在其中有一些php文件。

Inside del model folder I’ve a subfolder named include and inside this I’ve some php file.

结构类似于这样:

-模型

-mymodel.php

—mymodel.php

-包括
- file.php
— -file1.php

—include —-file.php —-file1.php

在mymodel.php内部,我如何包含file.php?

Inside mymodel.php how I can include the file.php?

我听说相对路径始终是index.php,所以我尝试了:

I’ve heard that the relative path is allways the index.php, so I’ve tried:

 include ‘models/include/file.php’

但它似乎不起作用。

我试图在没有运气的情况下使用base_url()和site_url()。

I’ve tried to use base_url() and site_url() without any luck..

有人可以帮助我吗?

Can anyone help me?

推荐答案

应这样做:

base_url().'application/models/include/file.php'

(URL帮助器必须加载以使用base_url()函数)

(url helper must be loaded to use the base_url() function)

如果您想要相对路径:

./application/models/include/file.php

所有文件都是相对文件到主要index.php,通常是

All files are relative to the main index.php, usually

这篇关于如何在Codeigniter的模型中包含文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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