浏览codeigniter的源代码,
在它的帮助函数中,我一直看到代码
$CI =& get_instance();
,任何人都可以向我解释这段代码是如何工作的?
我得到它返回对$ CI超级对象的引用,但是它get_instance()来自哪里?
我在CodeIgniter中开发了两个应用程序,两个都在单独的服务器上工作,即
www.CI_App_1.com
和
www.CI_App_2.com
现在,我要整合CI_App_2到CI_App_1应用程序,所以以后我能够调用default_controller的CI_App_2从环节之一CI_App_1.
我的文件夹结构:
htdocs :
-application_1
-application
-application_2
-application
-config
-autoload.php
-config.php
-routes.php
-controllers
-app_2_controller.php
-helpers
-libraries
-models
-app_2_model.php
-views
-app_2_view.php
-system
-.htaccess
-index.php
-config
-autoload.php
-config.php
-routes.php
-controllers
-app_1_controller.php
-helpers
-libraries
-models
-app_1_model.php
-views
-app_1_view.php
-system
-.htaccess
-index.php
Run Code Online (Sandbox Code Playgroud)
我希望在用户加入后访问CI_App_2 CI_App_1.验证过程后,用户只能访问我的CI_App_2,如果用户尝试访问它而不进行身份验证,则会收到一条错误消息:
访问被禁止
我提到以下链接:
在Application目录外调用CodeIgniter的Controller方法
http://www.techsirius.com/2013/01/load-controller-within-another.html
http://www.devnetwork.net/viewtopic.php?f=72&t=131353
如何设置在同一服务器上运行的两个codeigniter应用程序
https://www.codeigniter.com/user_guide/general/managing_apps.html
但是在上面的链接中他们说它应该使用HMVC模块结构来完成,但没有提到两个控制器文件来自相同的应用程序或不同.我想default_controller从第二个应用程序访问第一个应用程序.
可能吗 ?
任何形式的帮助表示赞赏.提前致谢.希望你有我的问题.
我正在尝试使用依赖的下拉列表框将过滤器应用于我的数据表.但是,当我尝试从下拉列表中选择一个值时,data-table只从一个下拉列表中获取值.
这是我的代码:
脚本:
<script type="text/javascript">
$(document).ready(function(){
var dataTable = $('#exampleProp').DataTable({
"processing": true,
"serverSide": true,
"dom": 'lfrtip',
"ajax": {
"url": "<?= base_url('Property/fetchProp'); ?>",
"dataType": "json",
"type": "POST"
},
"lengthMenu": [[50, 100, 200, -1], [50, 100, 200, "All"]],
// "ordering": false,
});
$('#areaId').on('change', function(){
if (this.value == 1) {
dataTable.search("Midlands & East of England").draw();
} else {
dataTable.search("North East, Yorkshire & Humberside").draw();
}
});
$('#cluster_id').on('change', function(){
dataTable.search(this.value).draw();
});
$('#prop_type').on('change', function(){
dataTable.search(this.value).draw();
});
$('#prop_status').on('change', function(){
dataTable.search(this.value).draw();
});
});
</script>
Run Code Online (Sandbox Code Playgroud)
在此,Cluster依赖于Area,但如果我选择Area,则它仅使用区域进行过滤,而不是使用cluster进行过滤.
以下是从数据库中选择群集列表的代码:
$('#areaId').change(function(){
var …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用Codeigniter 3.0添加第三方扩展来创建HMVC应用程序
但是,当我加入MY_Loader和MY_Router文件到核心文件和文件夹MX Third_party文件夹,它会产生一个致命的错误:
致命错误:在第300行的C:\ xampp\htdocs\codeigniter\application\third_party\MX\Loader.php中调用未定义的方法MY_Loader :: _ ci_object_to_array().
当我删除它们时,应用程序运行正常.是否有运行应用程序所需的其他设置?
我是wordpress的新手,我只是安装wordpress并想设置我的网站base_url.请任何人帮助我.提前致谢.
我试图将变量值从库函数传递给控制器,然后查看以获取输出。
为此,我的库代码:
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
/**
* @description : Library to access MyOperator Public API
*/
Class My_Operator extends Admin_controller{
protected $developers_url = 'https://developers.myoperator.co/';
protected $token = 'XXXXXXXXX';
function __construct() {
}
public function run() {
# request for Logs
$url = $this->developers_url . 'search';
$fields = array("token" => $this->token);
$result = $this->_post_api($fields, $url);
$this->log("result");
$this->log($result);
}
private function _post_api(Array $fields, $url) {
try {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, …Run Code Online (Sandbox Code Playgroud) 我在我的 Code-Igniter 应用程序中使用了谷歌图表(饼图)。我在仪表板视图页面上显示图表,并且得到了正确的结果。但是当我检查其他页面时出现错误
未捕获(承诺)错误:未定义容器。
错误:
未捕获(承诺)错误:未定义容器
在 gvjs_3m (jsapi_compiled_default_module.js:66)
在 gvjs_9K.gvjs_7p [作为构造函数] (jsapi_compiled_default_module.js:232)
在 gvjs_9K.gvjs_8K [作为构造函数] (jsapi_compiled_ui_module.js:979)
在新的 gvjs_9K (jsapi_compiled_ui_module.js:1010)
at drawChart (楼主Add:648)
在房东地址:623
在
我的图表代码:
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$.ajax({
url: "<?php echo base_url().'Dashboard/chartData'; ?>",
dataType: "JSON",
success:function(result){
google.charts.load('current',{
'packages':['corechart']
});
google.charts.setOnLoadCallback(function(){
drawChart(result);
});
//alert(result);
}
});
function drawChart(result) {
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('number', 'defects');
var dataArray = [];
$.each(result, function(i, obj) {
dataArray.push([obj.name, parseInt(obj.defects)]);
});
data.addRows(dataArray);
var piechart_options = {
title : …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用codeigniter将数组数据插入数据库.当我使用print_r()fun 打印这些值时.
它显示正确的结果,但是当我单击"保存"按钮时,它会在表格中插入空白值.
我只是想在处方表中存储多个药物名称,用于特定的prescription_id我试图使用insert_batch函数插入数据,但它保存了空白记录
这是我的型号代码:
public function add_prescription($data) {
$data['medicine_name'] = $data['medicine_nm[]'];
print_r($data['medicine_name']);
$this->db->insert_batch('pre',$data);
return $this->db->insert_id($pre_id);
}
Run Code Online (Sandbox Code Playgroud)
控制器代码 -
public function prescription($patient_id = NULL, $app_date = NULL, $hour = NULL , $min = NULL) {
//Check if user has logged in
if (!$this->session->userdata('user_name') || $this->session->userdata('user_name') == '') {
redirect('login/index/');
} else {
if ($this->form_validation->run() === FALSE) {
$data['medicine_nm[]']=$this->input->post('medicine_nm[]');
$this->patient_model->add_prescription($data);
}
}
}
Run Code Online (Sandbox Code Playgroud) 在处理我的一个PHP项目时,我debug_backtrace()在代码文件的开头得到了一个函数<?php debug_backtrace() || die ("Direct access not permitted"); ?>.
在研究它时,我得到了一些解释,它的工作原理是:
在 Drupal 网站中调试 PHP 问题可能是快速和容易的,也可能是严重的问题。PHP 包含一个名为 debug_backtrace 的调试函数,它将打印出直到调用 backtrace 函数的代码链。
当我使用var_dump()withdebug_backtrace()我得到以下结果:
array(2) {
[0]=>
array(3) {
["file"]=>
string(61) "C:\xampp\htdocs\folder_name\templates\default\models\home.php"
["line"]=>
int(30)
["function"]=>
string(7) "include"
}
[1]=>
array(4) {
["file"]=>
string(37) "C:\xampp\htdocs\folder_name\index.php"
["line"]=>
int(146)
["args"]=>
array(1) {
[0]=>
string(61) "C:\xampp\htdocs\folder_name\templates\default\models\home.php"
}
["function"]=>
string(7) "include"
}
}
Run Code Online (Sandbox Code Playgroud)
我不明白什么debug_backtrace()功能完全有效。
请任何人解释是受欢迎的。提前致谢。
学习链接:
php ×7
codeigniter ×5
javascript ×2
jquery ×2
.htaccess ×1
ajax ×1
api ×1
core ×1
datatables ×1
debugging ×1
html ×1
json ×1
mysql ×1
url ×1
url-routing ×1
wordpress ×1