Common usages in the CodeIgniter framework
This article mainly introduces the common usage of the CodeIgniter framework, and summarizes and analyzes common operating techniques such as CodeIgniter framework controllers, forms, and databases in the form of simple examples. Friends in need can refer to the following
The examples in this article describe Common uses of the CodeIgniter framework. Share it with everyone for your reference, the details are as follows:
1. codeigniter controller super object and attributes
$this->load; $this->load->database(); $this->load->view(); $this->load->helper();
$this->uri; $this->uri->segment(3);
$this->input;
2. Database configuration
$this->load->database(); $this->db->query('SELECT * FROM blog_user');
Configuring the exchange table prefix
$db['default']['dbprefix'] = 'blog_'; $db['default']['swap_pre'] = 'my_';
Then we use the table prefix my_ when writing sql statements, and ci will automatically replace my_ Bit blog_, so dbprefix can be modified at will, which is convenient for us to modify the database name.
For example:
$sql = "SELECT * FROM my_archive";
3. Form submission path
$this->load->helper('url');
Use
site_url('控制器/方法名')
4. Form verification (please refer to the previous article "CodeIgniter Form Verification Method Example Detailed Explanation" "And "Detailed Explanation of CI Framework Form Validation Examples")
5. SQL statement related
① Insert
$this->db->insert('archive',$archive); 返回bool值 $insert_id = $this->db->insert_id(); $this->db->insert_batch('archive',$data); //插入多条
② Query
$query = $this->db->query($sql); //返回Object $query->num_rows() 或者 $query->num_rows 返回查询出多少条 if($query->num_rows() > 0){ return $query->result();//$query->row() $query->result_array() $query->row_array() }else{ return false; } $query->last_query();
③ Update
$bool = $this->db->where('id >','74835')->update('archive', $data); $this->db->affected_rows(); //影响行数
④ Delete
$bool = $this->db->delete('tablename', array('id' => '500')); $bool = $this->db->where(array('id' => 500))->delete('tablename'); $this->db->affected_rows(); //影响行
The above is the entire content of this article, I hope it will be helpful to everyone’s study, more related content Please pay attention to PHP Chinese website!
Related recommendations:
How to use CodeIgniter to integrate Smarty
The above is the detailed content of Common usages in the CodeIgniter framework. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Summary of the system() function under Linux In the Linux system, the system() function is a very commonly used function, which can be used to execute command line commands. This article will introduce the system() function in detail and provide some specific code examples. 1. Basic usage of the system() function. The declaration of the system() function is as follows: intsystem(constchar*command); where the command parameter is a character.

With the popularity and development of the Internet, more and more people are beginning to develop their own websites and applications. PHP is a popular server-side programming language, and the CodeIgniter framework is an open source PHP framework that can help developers quickly build applications and improve development efficiency and code readability. This article will introduce how to use PHP and CodeIgniter framework for application development. Install PHP and CodeIgniter framework Before we start developing the application, we need to first

Summary of Git workflow management experience Introduction: In software development, version management is a very important link. As one of the most popular version management tools currently, Git's powerful branch management capabilities make team collaboration more efficient and flexible. This article will summarize and share the experience of Git workflow management. 1. Introduction to Git workflow Git supports a variety of workflows, and you can choose the appropriate workflow according to the actual situation of the team. Common Git workflows include centralized workflow, feature branch workflow, GitF

Summary reports are an essential skill for survival in the workplace. If you have a well-organized PPT summary report, it can not only save the leader's time, but also provide a focused summary of the work, which will definitely impress the leader. How to write a ppt summary report? Let’s take a look! We open a case file and explain based on this case. This case looks a bit outdated, as shown in the picture below. 2. Since we want to modify the PPT just now, let’s explain its existing problems in a targeted manner, as shown in the figure. 3. Here we introduce to students a [color matching] website, the vanschneider.com website. The website here is still very rich in color matching, as shown in the figure. 4. Here we prepare the PPT text material, and then

With huge advances in machine learning and quantum computing, we now have new and more powerful tools to collaborate with researchers across industries in new ways and radically accelerate the progress of groundbreaking scientific discoveries. The theme of this year's Google year-end summary is "Natural Science." The author of the article is John Platt, an outstanding scientist at Google Research. He graduated from the California Institute of Technology with a Ph.D. in 1989. Since joining Google Research eight years ago, I have been fortunate to be part of a community of talented researchers applying cutting-edge computing technologies to advance the possibilities of applied science. The team is currently exploring topics in the physical and natural sciences, from helping organizations The world's protein and genome information to benefit people's lives, to the extent of utilization

ThinkPHP is a popular PHP development framework that is flexible, efficient, and easy to use. It is widely used in the development of web applications. In long-term development practice, I have summarized some techniques to improve development efficiency, which I will share with you below. 1. Make full use of the core functions of ThinkPHP. ThinkPHP provides many powerful core functions, such as models, views, controllers, etc. We need to make full use of these functions to simplify the development process. First of all, we must use the MVC design pattern correctly and integrate the business

Summary of the margin attribute in CSS The margin attribute in CSS is used to set the margins of an element, which can control the spacing between the element and surrounding elements. This article will summarize the margin attribute and provide some specific code examples for reference. The margin attribute has four values, which represent the top, right, bottom and left margins of the element. You can set the margin value in the following ways: Single value: Set the margins in all directions to be equal. For example: .margin{margin:

Analysis and summary of application cases of Baidu AI interface in Java development. With the continuous development and application of artificial intelligence technology, Baidu AI interface, as one of them, is widely used in all walks of life. This article will analyze and summarize the application cases of Baidu AI interface in Java development, and illustrate its specific application methods and effects through code examples. 1. Overview of Baidu AI interface Baidu AI interface is a set of services provided to developers through API calls based on Baidu's artificial intelligence technology. It contains rich functions
