我从我的Web应用程序编写REST API.应用程序使用CodeIgniter框架编写.应用程序本身工作正常,但我仍然坚持进行REST身份验证.我认为基本的Http身份验证在一段时间内已经足够好了.公共API尚未规划.
是否有任何代码示例如何实现REST身份验证,因此在用户通过身份验证后,他可以自由调用所有受保护的方法.
为什么("2011/7/11")用json_encode显示器输出这个日期("2011\/7\/11")?
我怎样才能转换"2011\/7\/11"成"2011/7/11"?
$data_go = '2011/7/11';
$ddmmyyy='([1-9][\d]{3})[- \/.]([0-1][\d])[- \/.]([0-3][\d])';
if(preg_match("/$ddmmyyy$/", $data_go)) {
$year = substr($data_go,0,4);
$month = substr($data_go,5,2);
$day = substr($data_go,8,2);
$j2g = $this->convert_date->JalaliToGregorian($year, $month, $day);
$ok = $j2g[0]."/".$j2g[1]."/".$j2g[2];
}else {
return FALSE;
}
echo json_encode($ok); // output "2011\/7\/11"
Run Code Online (Sandbox Code Playgroud) 首先,update_batch上的Codeigniter文档不存在.kenjis非常友好地提供一些文档并将其提交到存储库.希望他们很快就拉下来.
有谁知道如何在Codeigniters update_batch命令中添加多个条件?
我想要的用途:
$where = array(
'title',
'name'
);
$this->db->update_batch('mytable', $data, $where);
Run Code Online (Sandbox Code Playgroud)
当我尝试这段代码时,我得到了以下错误:
A Database Error Occurred
One or more rows submitted for batch updating is missing the specified index.
Filename: C:\wamp\www\wheel\system\database\DB_active_rec.php
Line Number: 1451
Run Code Online (Sandbox Code Playgroud)
由kenjis更新批处理文档:
$this->db->update_batch();
Run Code Online (Sandbox Code Playgroud)
根据您提供的数据生成更新字符串,然后运行查询.您可以将数组或对象传递给函数.以下是使用数组的示例:
$data = array(
array(
'title' => 'My title' ,
'name' => 'My Name 2' ,
'date' => 'My date 2'
),
array(
'title' => 'Another title' ,
'name' => 'Another Name 2' ,
'date' => 'Another date …Run Code Online (Sandbox Code Playgroud) 所以我可以删除一行:
$this->db->delete($tableName,array("id"=>4));
Run Code Online (Sandbox Code Playgroud)
...但我无法弄清楚如何删除多行.我试过了:
$this->db->delete($tableName,array("id"=>4,"id"=5));
Run Code Online (Sandbox Code Playgroud)
以及:
$this->db->delete($tableName,array(array("id"=>4),array("id"=5)));
Run Code Online (Sandbox Code Playgroud)
......但它们都不起作用.我觉得这应该很容易.任何答案?
我是codeigniter的新手,我正在使用v.2.12.我尝试从外部文件加载css时收到错误.
我在应用程序文件夹中创建了css文件夹.我以all.css的名义创建了css文件.
在视图文件中,我使用以下代码链接css文件.
<link rel="stylesheet" type="text/css" href="<? echo base_url();?>css/all.css">
Run Code Online (Sandbox Code Playgroud)
但是css文件没有加载.我收到404错误.这是我的配置设置:
$config['base_url'] = 'http://webscarlets.com/ci/index.php';
$config['index_page'] = 'index.php';
Run Code Online (Sandbox Code Playgroud)
我正在尝试在我的模型中指定查询
$this->db
->select('*')
->from('library')
->where('library.rating >=', $form['slider'])
->where('library.votes >=', '1000')
->where('library.language !=', 'German')
->where('library.available_until >=', date("Y-m-d H:i:s"))
->or_where('library.available_until =', "00-00-00 00:00:00")
->where('library.release_year >=', $year_start)
->where('library.release_year <=', $year_end)
->join('rating_repo', 'library.id = rating_repo.id')
Run Code Online (Sandbox Code Playgroud)
所以,我遇到的麻烦就是我的or_where.我希望or仅限于该available_until领域.然而,目前,我得到的结果是德语不是我想要的.如何将我的or_where过滤器限制在该available_until字段中?
我已经阅读了很多类似的问题,它们可能看似重复,但没有人问我到底要问什么,更重要的是:没有人有我想要的答案!
它非常简单:我只想$variable在几个地方使用:不仅包括视图和控制器,还包括routes.php其他配置文件.
我不想要这样的事情:使用Config类加载配置文件; 使用CI get_instance等等.
我只是想声明一个给定的$variable(它可能是一个常量,但我需要它作为变量),并且绝对在任何地方使用它.
事实上......我想知道CI引导程序中的哪个PHP文件是最先被解析的文件之一,所以我可以在那里引入我的全局变量......但不是核心/系统或不相关的文件,但是这个简单要求的"最佳"适合放置.
谢谢.
我在XAMPP中部署了我的源代码.我遇到了以下错误.
注意:在第257行的C:\ xampp\htdocs\3c_app\public_html\system\core\Common.php中只能通过引用返回变量引用
致命错误:在C:\ xampp\htdocs\3c_app中找不到类'CI_Controller'第233行的\ public_html\system\core\CodeIgniter.php.
我的源文件是:
的common.php
// Are any values being dynamically replaced?
if (count($replace) > 0)
{
foreach ($replace as $key => $val)
{
if (isset($config[$key]))
{
$config[$key] = $val;
}
}
}
return $_config[0] =& $config;
}
Run Code Online (Sandbox Code Playgroud)
第257行是: return $_config[0] =& $config;和
Codeigniter.php
// Fetch the config file
if ( ! file_exists($file_path))
{
exit('The configuration file does not exist.');
}
require($file_path);
Run Code Online (Sandbox Code Playgroud)
第233行: if ( ! file_exists($file_path))
任何人都可以帮忙???
这将是codeigniter框架的最佳ORM.我看到了一些类似的问题,但它太旧了,链接不起作用.任何人都可以帮我解决这个问题吗?
我正在使用新版本(3.0.0).CodeIgniter和我有一个新问题,我的会话不起作用.我的意思是,控制器中的代码是正确的,因为没有错误但是,当我尝试在视图中打印PHP变量时,什么都没有.
我在MySQL服务器上检查了我的表,什么都没有,我现在不知道是什么问题.我把我的config.php代码.(我对这个新版本中的很多东西都不了解)
$config['sess_table_name'] = 'ci_sessions';
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
Run Code Online (Sandbox Code Playgroud)
我必须添加第一行到"make"会话工作,我不知道该配置是否正确在数据库中进行会话.
如果有人有同样的问题,请帮助我:(.我的会话课程尚未编辑.
codeigniter ×10
php ×8
activerecord ×2
mysql ×2
database ×1
date ×1
frameworks ×1
global ×1
json ×1
orm ×1
rest ×1
session ×1