使用新的Codeigniter 3.0版本,您使用哪些身份验证库?
ci_sessions模式,我看到它有很多工作需要重写所有使用会话的代码部分.它似乎适用于文件会话和其代码的一些更改.那么,是否有人在大型CI 3.0 Web应用程序上成功集成(或迁移)了前面提到的任何库?你自己写的吗?你是否坚持使用CI 2直到进一步的CI 3.0开发?
这篇关于 codeigniter中的身份验证库的帖子非常受欢迎且非常有用.我认为,至少在一些有用的答案之前,不应该关闭以这种方式帮助社区的帖子.它之前没有讨论过,我真的希望看到更有经验的开发人员的意见.
我正在使用Codeigniter交易
$this->db->trans_start();
$this->db->query('AN SQL QUERY...');
$this->db->trans_complete();
Run Code Online (Sandbox Code Playgroud)
这工作得很好,我有问题是内部的trans_start和trans_complete我打电话等功能,这些功能与数据库交易,使他们包含插入和更新以及一些删除...例如:
$this->db->trans_start();
$this->utils->insert_function($data);
$this->utils->update_function2($test);
$this->db->trans_complete();
Run Code Online (Sandbox Code Playgroud)
现在,如果执行这些函数并且发生一些错误,CodeIgniter将不会执行回滚.
处理此类问题的最佳方法是什么?
我想到的唯一解决方案是从这些函数返回错误并在那些函数内添加(trans_stat和trans_complete)如果它返回错误测试则执行$this->db->trans_rollback
例如:
$this->db->trans_start();
$result = $this->utils->insert_function($data);
if($result === false){
$this->db->trans_rollback();
}
$this->db->trans_complete();
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法呢?
更新1:
根据要求我正在调用的外部函数示例:
// insert_function contains
$rec = array(
'numero' => $numero,
'transaction_id' => $id,
'debit' => $product_taxes['amount_without_taxes'],
'date' => $data['date_transaction'],
);
$this->addExerciceAccountingRecords($rec);
and addExerciceAccountingRecords contains
function addExerciceAccountingRecords($records) {
$this->db->insert('transactions_exercices', $records);
}
Run Code Online (Sandbox Code Playgroud) 安装新的 xampp 版本(php8)后出现此错误。并克隆我的 codeigniter 项目。
Message: Return type of CI_Session_files_driver::open($save_path, $name)
should either be compatible with SessionHandlerInterface::open(string $path, string $name):
bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Run Code Online (Sandbox Code Playgroud)
文件名:drivers/Session_files_driver.php
线路号码:132
我看到在他们的默认安装中,他们的index.php有这样的:
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
Run Code Online (Sandbox Code Playgroud)
为什么会CI_ENV曾经已经在内部设置$_SERVER阵列?
我正在CodeIgniter中编写一个应用程序,我<title>在每个控制器的每个页面上指定元标记,我已设法将其发送到我的标题模板.但是,现在我已经创建了一个应用程序,通过CodeIgniter模型从数据库中获取信用卡及其标题.我想自动获取并使用信用卡的名称,<title>这样我就不需要手动更改它了,但我有点不知道如何继续.
这是我现在的代码:
调节器
public function show($card = NULL)
{
$data['query'] = $this->Listing_model->get_card($card);
$header["page_title"] = from the model
$this->load->view('includes/header',$header);
$this->load->view('listings/listing_card',$data);
$this->load->view('includes/footer');
}
Run Code Online (Sandbox Code Playgroud)
模型
function get_card($card = FALSE)
{
$query = $this->db->get_where('creditcards', array('slug' => $card), 0,1);
return $query->result();
}
Run Code Online (Sandbox Code Playgroud)
我在创建这个应用程序时一直遵循官方的CodeIgniter文档,但到目前为止还没有运气.有解决方案吗
在SQL Server我们可以在下面写SQL Queries让数据库取消提交的数据.这意味着仍在交易和交易中的数据不完整.
SQL Server查询
Select * from TableName With(NoLock);
Run Code Online (Sandbox Code Playgroud)
即使表被锁定,MySQL数据库中是否有任何等价来获取数据?我在PHP CodeIgnitor中尝试这个
我正在尝试创建以下语句:
select * from donors where field is NOT NULL;
Run Code Online (Sandbox Code Playgroud)
使用codeigniter,我的代码如下所示:
$where = ['field' => NULL];
$this->db->get_where('table', $where);
Run Code Online (Sandbox Code Playgroud) 我在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))
任何人都可以帮忙???
我正在使用新版本(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 3作为Web平台,并尝试将语义UI UI导入到我的页面中.我是通过base_url()在CSS导入的href属性中使用CodeIgniter的方法来实现的.
但是,semantic.css本身会导入我服务器上存在的其他一些字体,然后由于跨源资源共享策略而无法加载这些字体.这是chrome给我的错误消息:
来自"来源" http://[::1]的字体已被阻止通过跨源资源共享策略加载:请求的资源上不存在"Access-Control-Allow-Origin"标头.原产地" :HTTP //本地主机,因此"是不允许访问.
这是因为[::1]我输入浏览器时,base_url()回应域已经存在而不是localhost.
出于某种原因,在我看来,chrome(以及Edge)并不认为[::1]和localhost是同一个主机,或者我可能只是愚蠢.我所知道的是,如果我将主semantic.css文件的路径和硬代码localhost更改为它,它可以工作,如果不是使用localhost请求我的页面,它也可以使用[::1]
我已经完成了与此类似的其他项目,从未"[::1]"出现过这种情况.究竟是什么导致php回应这样的路径?