Upload
weerayut-hongsa
View
351
Download
0
Embed Size (px)
Citation preview
CodeIgniter For ProjectLesson 105 : Helper and Library
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
Helper
“Helpers, as the name suggests, help you with tasks. Each helper file is simply a collection of functions in a particular
category”
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
Helper load code
• $this->load->helper([helper name]);
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
You can load helper on constructor and function in Controller
Helper frequently used
• url : URL helper utility
• form : Form helper utility
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
url : URL helper utility
• site_url() : Get current url your website.
• base_url() : Get current base path.
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
url : URL helper utility• base_url()
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
url : URL helper utility• site_url()
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
form : Form helper utility
• form_open() : Auto form open generate
• form_close() : Auto form close generate
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
form : Form helper utility• form_open()
• form_close()
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
Library
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
Library load code
• $this->load->library([library name]);
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
You can load library on constructor and function in Controller
Library frequently used
• session : CodeIgniter session library
• input : CodeIgniter input library (autoload)
• load : CodeIgniter library loader (autoload)
• form_validation : CodeIgniter form validate library
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
session : CodeIgniter session library
• $this->session->set_userdata() : Set user data session
• $this->session->unset_userdata() : Unset user data session
• $this->session->userdata() : Read data from session
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
session : CodeIgniter session library• $this->session->set_userdata()
• $this->session->unset_userdata()
• $this->session->userdata()
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
input : CodeIgniter input library (autoload)
• $this->input->post() : Get value from post method
• $this->input->get() : Get value from get method
• $this->input->cookie() : Get value from cookie
• $this->input->server() : Get value from server variable
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
• $this->input->post()
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
input : CodeIgniter input library (autoload)
• $this->input->get()
input : CodeIgniter input library (autoload)
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
form_validation : CodeIgniter form validate library
• $this->form_validation->set_rules() : Set form validate rule
• $this->form_validation->run() : Begin validation from rules
• validation_errors() : Show error if validation not pass
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
form_validation : CodeIgniter form validate library
• $this->form_validation->set_rules()
• $this->form_validation->run()
• validation_errors()
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
form_validation : CodeIgniter form validate library
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com
Rules in set_rules method
Forward to Workshop 004
Weerayut Hongsa : Network Engineer / Software Developer Major Kantana Broadcasting Co., Ltd
https://kusumotolab.com