codeigniter

How to get show_error() in CodeIgniter to load a view?

天大地大妈咪最大 提交于 2019-12-31 02:57:27
问题 I need to load a head view and a foot view in all my pages. But show_error uses its own complete template. And it stops execution after it loads this template, so the footer wouldn't even load if I wanted to. Should I override this method or is there another way? 回答1: You can create a custom layout to the error messages in the application/errors directory. EDIT: If you want to use your existing files you can do one of the following: If you only require the 404 error page, you can set a custom

Problem with cyrillic characters in friendly url

北城以北 提交于 2019-12-31 02:31:56
问题 Here's the thing. I have friendly urls like http://site.com/blog/read/мъдростта-на-вековете http://site.com/blog/read/green-apple The last segment is actually the friendly title of the blog article. The problem is when I try to pass that segment to the database, the cyrillic fonts turn into something like %D1%8A%D0%B4%D1%80%D0%BE%D1%81%D1%8 and couldn't match the database record. In the address bar in my browser it looks normal ( мъдростта-на-вековете ) but if I choose 'copy url location' the

Error Class Controller not found in CodeIgniter

谁都会走 提交于 2019-12-31 02:29:44
问题 Hello, I am getting Controller not found error in CodeIgniter. This is my Controller code <?php class HelloWorld extends Controller { function HelloWorld() { parent::Controller(); } function index() { $this->load->view('index_view'); } function hello() { $this->load->view('hello_view'); } } ?> This is the view code: Hello, Nice to see you! I have this error when it executes: Fatal error: Class 'Controller' not found in D:\wamp\www\CodeIgniter_2.0.2\application\controllers\helloworld.php on

Issue executing stored procedure from PHP to a Microsoft SQL SERVER

*爱你&永不变心* 提交于 2019-12-31 02:28:08
问题 I am using the code igniter framework. And I been trying to execute a stored procedure(no params) I wrote on Microsoft SQL Server 2008 from PHP but i get an error . This stored procedure runs good on Microsoft SQL Server with no errors. I am using sqlsrv as the driver and I have a PHP version 5.2 if that helps. This is the error I get Error Number: 01000 [Microsoft][SQL Server Native Client 10.0][SQL Server]Executing SQL directly; no cursor Exec sp_test The following is part of the code I

how to convert multiple html files with Dompdf?

心已入冬 提交于 2019-12-31 02:08:43
问题 What I am Doing: I am using a PHP library called Dompdf to convert my HTML file into PDF. I have successful converted a single HTML file to PDF. What I am trying to do: Now I have multiple reports I want to convert them into PDF file. What I am doing: I have a example here in which I'm a getting a form from database and another one by direct from view. Code: $result['patients'] = $this->reports_model->get_xray_reports($id); // getting form from database require_once "dompdf/dompdf_config.inc

Codeigniter db->update() VS MySQL native UPDATE Affected rows: 0

℡╲_俬逩灬. 提交于 2019-12-31 02:01:46
问题 Using MySQL alone - If I make a basic update to a table like this: UPDATE `SOMETABLE` SET `NAME` = 'John' WHERE `ID` = 1; And the value of NAME = ' John ' was already ' John ' - in other-words - nothing is new, nothing to update. MySQL returns " Affected rows: 0 (Query took 0.0007 sec) " If I make the same call - now using CodeIgniter - and then retrieve the affected rows like this: $data = array( 'NAME' => 'John' ); $this->db->where('ID', 1); $this->db->update('SOMETABLE', $data); $affect =

Hooks in Codeigniter

核能气质少年 提交于 2019-12-31 00:23:05
问题 How can I call a hook for only a few controllers instead of all controllers in CodeIgniter? E.g.: I want to run the hook for only the admin section. How can I achieve this? 回答1: In the hook which you wish to run selectively, you can access the ci superobject using $this->ci =& get_instance(); . This acts as a pointer which can be used to access the CodeIgniter router to determine the class using $class = $this->ci->router->fetch_class(); . You can then check if $class matches a certain value.

How to do a negative form validation in codeigniter?

浪子不回头ぞ 提交于 2019-12-30 20:37:06
问题 is_unique is the form validation which not allow the value exist in the database. But, can I do the opposite one? for example, I would like to need the value which is exist in the database, so, I make the rules like this: $this->form_validation->set_rules('email', 'Email', 'required|max_length[32]|valid_email|(!(is_unique[users.email]))'); But it seems not success as I expected, any recommends? Thanks. 回答1: You can do it like this $this->form_validation->set_rules('email', 'Email', 'required

How to do a negative form validation in codeigniter?

≡放荡痞女 提交于 2019-12-30 20:35:31
问题 is_unique is the form validation which not allow the value exist in the database. But, can I do the opposite one? for example, I would like to need the value which is exist in the database, so, I make the rules like this: $this->form_validation->set_rules('email', 'Email', 'required|max_length[32]|valid_email|(!(is_unique[users.email]))'); But it seems not success as I expected, any recommends? Thanks. 回答1: You can do it like this $this->form_validation->set_rules('email', 'Email', 'required

Codeigniter 用户登录注册模块

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-30 18:37:47
Codeigniter 用户登录注册模块 以下皆是基于Codeigniter + MySQL 一、要实现用户登录注册功能,首先就要和MySQL数据库连接,操作流程如下: CI中贯彻MVC模型,即Model + View + Controller。数据模型Model处理数据库的运算,视图View顾名思义即使将数据显示出来的页面,而控制器Controller是用来代理完成某项任务的PHP类,Controller充当MVC架构应用程序的“粘合剂”。再回到数据模型,通过创建控制器类,可以对数据库或者其他数据存储方式进行取回、插入和更新。CI中要使用数据库,首先要在配置文件“application/config/database.php”中对数据库进行配置,包括数据库名、用户名、密码等。以下代码段继承控制器CI_Model类,获得数据表‘news’,并对数据表‘news’进行了读和写的简单操作: <?php class News_model extends CI_Model{ public function __construct() { $this->load->database(); } public function get_news($slug = FALSE) { if($slug == FALSE) { $query = $this->db->get('news'); //获得