SlideShare a Scribd company logo
CodeIgniter Class Reference
Jamshid Hashimi
Trainer, Cresco Solution
http://www.jamshidhashimi.com
jamshid@netlinks.af
@jamshidhashimi
ajamshidhashimi
Afghanistan Workforce
Development Program
Agenda
• Database Class
• Calendar Class
• Config Class
• Email Class
• File Uploading Class
• Form Validation Class
Database Class
• CodeIgniter comes with a full-featured and
very fast abstracted database class that
supports both traditional structures and
Active Record patterns. The database
functions offer clear, simple syntax.
• Usage Examples
$this->load->database();
$DB1 = $this->load->database('group_one', TRUE);
$DB2 = $this->load->database('group_two', TRUE);
Database Class
• Configuration
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = 'root';
$db['default']['password'] = '';
$db['default']['database'] = 'sakila';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
Database Class
• Standard Query
• Result
$query = $this->db->query('SELECT
name, title, email FROM my_table');
$query->result() //Object
$query->result_array() //Array
Database Class
• Testing Result
• Single Result
if ($query->num_rows() > 0)
$query = $this->db->query('SELECT name FROM
my_table LIMIT 1');
$row1 = $query->row();
$row2 = $query->row_array();
echo $row1->name;
echo $row2[‘name’];
Database Class
• Affected Rows
$sql = "INSERT INTO mytable (title, name)
VALUES (".$this->db->escape($title).", ".$this-
>db->escape($name).")";
$this->db->query($sql);
echo $this->db->affected_rows();
Database Class
• Query Helper Functions
$this->db->insert_id();
$this->db->affected_rows();
$this->db->count_all();
$this->db->platform();
$this->db->version();
$this->db->last_query();
Database Class
• Active Record – Selecting Data
• Selecting Data – LIMIT
$query = $this->db->get('mytable');
// Produces: SELECT * FROM mytable
$query = $this->db->get('mytable', 10, 20);
// Produces: SELECT * FROM mytable LIMIT 20, 10
Database Class
• Selecting Data – Result
• get_where()
$query = $this->db->get('mytable');
foreach ($query->result() as $row)
{
echo $row->title;
}
$query = $this->db->get_where('mytable',
array('id' => $id), $limit, $offset);
Database Class
• $this->db->select();
• $this->db->select_max();
• $this->db->select_min();
• $this->db->select_avg();
• $this->db->select_sum();
• $this->db->from();
• $this->db->where();
• $this->db->join();
Database Class
• $this->db->or_where();
• $this->db->where_in();
• $this->db->or_where_in();
• $this->db->where_not_in();
• $this->db->or_where_not_in();
• $this->db->like();
• $this->db->or_like();
• $this->db->not_like();
• $this->db->or_not_like();
Database Class
• $this->db->group_by();
• $this->db->distinct();
• $this->db->having();
• $this->db->or_having();
• $this->db->order_by();
Database Class
• Inserting Data
– $this->db->insert();
$data = array(
'title' => 'My title' ,
'name' => 'My Name' ,
'date' => 'My date'
);
$this->db->insert('mytable', $data);
// Produces: INSERT INTO mytable (title,
name, date) VALUES ('My title', 'My name',
'My date')
Database Class
• Inserting Data
– $this->db->insert_batch();
$data = array(
array(
'title' => 'My title' ,
'name' => 'My Name' ,
'date' => 'My date'
),
array(
'title' => 'Another title' ,
'name' => 'Another Name' ,
'date' => 'Another date'
)
);
$this->db->insert_batch('mytable', $data);
Database Class
• Updating Data
– $this->db->update();
$data = array(
'title' => $title,
'name' => $name,
'date' => $date
);
$this->db->where('id', $id);
$this->db->update('mytable', $data);
Database Class
• Updating Data
– $this->db->update_batch();
$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 2'
)
);
$this->db->update_batch('mytable', $data,
'title');
Database Class
• Deleting Data
– $this->db->delete();
– $this->db->truncate();
• Method Chaining
$this->db->where('id', $id);
$this->db->delete('mytable');
DEMO
Calendar Class
• The Calendar class enables you to dynamically
create calendars. Your calendars can be
formatted through the use of a calendar
template, allowing 100% control over every
aspect of its design. In addition, you can pass
data to your calendar cells.
echo $this->calendar->generate();
echo $this->calendar->generate(2006, 6);
DEMO
Config Class
• The Config class provides a means to retrieve
configuration preferences.
$this->config->item('item name');
$this->config->set_item('item_name', 'item_value');
DEMO
Email Class
• Multiple Protocols: Mail, Sendmail, and SMTP
• Multiple recipients
• CC and BCCs
• HTML or Plaintext email
• Attachments
• Word wrapping
• Priorities
• BCC Batch Mode, enabling large email lists to be
broken into small BCC batches.
• Email Debugging tools
Email Class
Email Class
$this->load->library('email');
$this->email->from('your@example.com', 'Your Name');
$this->email->to('someone@example.com');
$this->email->cc('another@another-example.com');
$this->email->bcc('them@their-example.com');
$this->email->subject('Email Test');
$this->email->message('Testing the email class.');
$this->email->send();
echo $this->email->print_debugger();
Email Class
• Send email with Gmail
$this->load->library('email');
$config = Array(
'protocol' => 'smtp',
'smtp_host' => 'ssl://smtp.googlemail.com',
'smtp_port' => 465,
'smtp_user' => 'youremail@gmail.com',
'smtp_pass' => 'yourpassword',
);
Email Class
• Initialize Configuration
$config['protocol'] = 'sendmail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'iso-8859-1';
$config['wordwrap'] = TRUE;
$this->email->initialize($config);
Email Class
• Attachments
$this->email->attach('/path/to/photo1.jpg');
$this->email->attach('/path/to/photo2.jpg');
$this->email->attach('/path/to/photo3.jpg');
$this->email->send();
File Upload Class
• CodeIgniter's File Uploading Class permits files
to be uploaded. You can set various
preferences, restricting the type and size of
the files.
$this->upload->do_upload();
$this->upload->display_errors();
$this->upload->data();
File Upload Class
• Initializing Configurations
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
DEMO
Form Validation Class
• CodeIgniter provides a comprehensive form
validation and data prepping class that helps
minimize the amount of code you'll write.
<?php echo validation_errors(); ?>
$this->form_validation->run()
Form Validation Class
DEMO
Assignments
QUESTIONS?

More Related Content

KEY
Zf Zend Db by aida
waraiotoko
 
PPTX
Drupal II: The SQL
ddiers
 
PDF
Drupal - dbtng 25th Anniversary Edition
ddiers
 
PDF
Dependency Injection
Rifat Nabi
 
PDF
WordPress Transients
Tammy Hart
 
PPTX
MUC - Moodle Universal Cache
Tim Hunt
 
PPTX
[PHP] Zend_Db (Zend Framework)
Jun Shimizu
 
PDF
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Cliff Seal
 
Zf Zend Db by aida
waraiotoko
 
Drupal II: The SQL
ddiers
 
Drupal - dbtng 25th Anniversary Edition
ddiers
 
Dependency Injection
Rifat Nabi
 
WordPress Transients
Tammy Hart
 
MUC - Moodle Universal Cache
Tim Hunt
 
[PHP] Zend_Db (Zend Framework)
Jun Shimizu
 
Temporary Cache Assistance (Transients API): WordCamp Birmingham 2014
Cliff Seal
 

What's hot (20)

PDF
Dependency Injection
Fabien Potencier
 
PDF
Dependency Injection with PHP and PHP 5.3
Fabien Potencier
 
PDF
Dependency Injection in Laravel
HAO-WEN ZHANG
 
PDF
Doctrine MongoDB Object Document Mapper
Jonathan Wage
 
PPTX
Learn PHP Lacture2
ADARSH BHATT
 
PDF
ZendCon2010 Doctrine MongoDB ODM
Jonathan Wage
 
PDF
Symfony Day 2010 Doctrine MongoDB ODM
Jonathan Wage
 
PDF
Managing a shared_mysql_farm_phpday2011
Combell NV
 
PPTX
GraphQL API for Frontend Devs
Chris Nwamba
 
PDF
Symfony2 from the Trenches
Jonathan Wage
 
PDF
CakeFest 2013 keynote
José Lorenzo Rodríguez Urdaneta
 
PDF
Doctrine 2
zfconfua
 
PDF
Jan Lehnardt Couch Db In A Real World Setting
George Ang
 
PDF
PHP Data Objects
Wez Furlong
 
PPTX
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
Jose Luis Martínez
 
PPT
DBIC 2 - Resultsets
Aran Deltac
 
KEY
Geospatial Indexing and Querying with MongoDB
Grant Goodale
 
PDF
50 Laravel Tricks in 50 Minutes
Azim Kurt
 
KEY
PHP Development With MongoDB
Fitz Agard
 
Dependency Injection
Fabien Potencier
 
Dependency Injection with PHP and PHP 5.3
Fabien Potencier
 
Dependency Injection in Laravel
HAO-WEN ZHANG
 
Doctrine MongoDB Object Document Mapper
Jonathan Wage
 
Learn PHP Lacture2
ADARSH BHATT
 
ZendCon2010 Doctrine MongoDB ODM
Jonathan Wage
 
Symfony Day 2010 Doctrine MongoDB ODM
Jonathan Wage
 
Managing a shared_mysql_farm_phpday2011
Combell NV
 
GraphQL API for Frontend Devs
Chris Nwamba
 
Symfony2 from the Trenches
Jonathan Wage
 
CakeFest 2013 keynote
José Lorenzo Rodríguez Urdaneta
 
Doctrine 2
zfconfua
 
Jan Lehnardt Couch Db In A Real World Setting
George Ang
 
PHP Data Objects
Wez Furlong
 
MooseX::Datamodel - Barcelona Perl Workshop Lightning talk
Jose Luis Martínez
 
DBIC 2 - Resultsets
Aran Deltac
 
Geospatial Indexing and Querying with MongoDB
Grant Goodale
 
50 Laravel Tricks in 50 Minutes
Azim Kurt
 
PHP Development With MongoDB
Fitz Agard
 
Ad

Similar to CodeIgniter Class Reference (20)

PPTX
DrupalCamp Foz - Novas APIs Drupal 7
chuvainc
 
PPTX
Drupal7 dbtng
Nicolas Leroy
 
PPTX
Drupal 8 database api
Viswanath Polaki
 
PPTX
15. CodeIgniter editarea inregistrarilor
Razvan Raducanu, PhD
 
PDF
The History of PHPersistence
Hugo Hamon
 
PDF
Database API, your new friend
kikoalonsob
 
PPTX
21. CodeIgniter search
Razvan Raducanu, PhD
 
PDF
Desarrollo de módulos en Drupal e integración con dispositivos móviles
Luis Curo Salvatierra
 
KEY
About Data::ObjectDriver
Yoshiki Kurihara
 
KEY
Unit testing zend framework apps
Michelangelo van Dam
 
PDF
Scaling Databases with DBIx::Router
Perrin Harkins
 
PDF
[WLDN] Supercharging word press development in 2018
Adam Tomat
 
PDF
The State of Lithium
Nate Abele
 
PDF
Doctrine MongoDB ODM (PDXPHP)
Kris Wallsmith
 
PDF
Slow Database in your PHP stack? Don't blame the DBA!
Harald Zeitlhofer
 
PPTX
Pitfalls to Avoid for Cascade Server Newbies by Lisa Hall
hannonhill
 
PDF
The Zen of Lithium
Nate Abele
 
PPTX
This slide show will brief about database handling
averynight005
 
PDF
WordPress as an application framework
Dustin Filippini
 
KEY
究極のコントローラを目指す
Yasuo Harada
 
DrupalCamp Foz - Novas APIs Drupal 7
chuvainc
 
Drupal7 dbtng
Nicolas Leroy
 
Drupal 8 database api
Viswanath Polaki
 
15. CodeIgniter editarea inregistrarilor
Razvan Raducanu, PhD
 
The History of PHPersistence
Hugo Hamon
 
Database API, your new friend
kikoalonsob
 
21. CodeIgniter search
Razvan Raducanu, PhD
 
Desarrollo de módulos en Drupal e integración con dispositivos móviles
Luis Curo Salvatierra
 
About Data::ObjectDriver
Yoshiki Kurihara
 
Unit testing zend framework apps
Michelangelo van Dam
 
Scaling Databases with DBIx::Router
Perrin Harkins
 
[WLDN] Supercharging word press development in 2018
Adam Tomat
 
The State of Lithium
Nate Abele
 
Doctrine MongoDB ODM (PDXPHP)
Kris Wallsmith
 
Slow Database in your PHP stack? Don't blame the DBA!
Harald Zeitlhofer
 
Pitfalls to Avoid for Cascade Server Newbies by Lisa Hall
hannonhill
 
The Zen of Lithium
Nate Abele
 
This slide show will brief about database handling
averynight005
 
WordPress as an application framework
Dustin Filippini
 
究極のコントローラを目指す
Yasuo Harada
 
Ad

More from Jamshid Hashimi (20)

PPTX
Week 2: Getting Your Hands Dirty – Part 2
Jamshid Hashimi
 
PPTX
Week 1: Getting Your Hands Dirty - Part 1
Jamshid Hashimi
 
PPTX
Introduction to C# - Week 0
Jamshid Hashimi
 
PPTX
RIST - Research Institute for Science and Technology
Jamshid Hashimi
 
PPTX
How Coding Can Make Your Life Better
Jamshid Hashimi
 
PPTX
Mobile Vision
Jamshid Hashimi
 
PPTX
Tips for Writing Better Code
Jamshid Hashimi
 
PPTX
Launch Your Local Blog & Social Media Integration
Jamshid Hashimi
 
PPTX
Customizing Your Blog 2
Jamshid Hashimi
 
PPTX
Customizing Your Blog 1
Jamshid Hashimi
 
PPTX
Introduction to Blogging
Jamshid Hashimi
 
PPTX
Introduction to Wordpress
Jamshid Hashimi
 
PPTX
CodeIgniter Helper Functions
Jamshid Hashimi
 
PPTX
Managing Applications in CodeIgniter
Jamshid Hashimi
 
PPTX
CodeIgniter Practice
Jamshid Hashimi
 
PPTX
CodeIgniter & MVC
Jamshid Hashimi
 
PPTX
PHP Frameworks & Introduction to CodeIgniter
Jamshid Hashimi
 
PPTX
Exception & Database
Jamshid Hashimi
 
PPTX
MySQL Record Operations
Jamshid Hashimi
 
PPTX
MySQL JOIN & UNION
Jamshid Hashimi
 
Week 2: Getting Your Hands Dirty – Part 2
Jamshid Hashimi
 
Week 1: Getting Your Hands Dirty - Part 1
Jamshid Hashimi
 
Introduction to C# - Week 0
Jamshid Hashimi
 
RIST - Research Institute for Science and Technology
Jamshid Hashimi
 
How Coding Can Make Your Life Better
Jamshid Hashimi
 
Mobile Vision
Jamshid Hashimi
 
Tips for Writing Better Code
Jamshid Hashimi
 
Launch Your Local Blog & Social Media Integration
Jamshid Hashimi
 
Customizing Your Blog 2
Jamshid Hashimi
 
Customizing Your Blog 1
Jamshid Hashimi
 
Introduction to Blogging
Jamshid Hashimi
 
Introduction to Wordpress
Jamshid Hashimi
 
CodeIgniter Helper Functions
Jamshid Hashimi
 
Managing Applications in CodeIgniter
Jamshid Hashimi
 
CodeIgniter Practice
Jamshid Hashimi
 
CodeIgniter & MVC
Jamshid Hashimi
 
PHP Frameworks & Introduction to CodeIgniter
Jamshid Hashimi
 
Exception & Database
Jamshid Hashimi
 
MySQL Record Operations
Jamshid Hashimi
 
MySQL JOIN & UNION
Jamshid Hashimi
 

Recently uploaded (20)

PDF
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
PDF
This slide provides an overview Technology
mineshkharadi333
 
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
PDF
madgavkar20181017ppt McKinsey Presentation.pdf
georgschmitzdoerner
 
PDF
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PDF
Enable Enterprise-Ready Security on IBM i Systems.pdf
Precisely
 
PDF
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
PDF
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
PDF
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
Google’s NotebookLM Unveils Video Overviews
SOFTTECHHUB
 
PDF
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
CIFDAQ
 
PPT
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
PDF
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
PDF
Software Development Company | KodekX
KodekX
 
PDF
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 
Chapter 2 Digital Image Fundamentals.pdf
Getnet Tigabie Askale -(GM)
 
This slide provides an overview Technology
mineshkharadi333
 
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
codernjn73
 
madgavkar20181017ppt McKinsey Presentation.pdf
georgschmitzdoerner
 
agentic-ai-and-the-future-of-autonomous-systems.pdf
siddharthnetsavvies
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
Enable Enterprise-Ready Security on IBM i Systems.pdf
Precisely
 
Building High-Performance Oracle Teams: Strategic Staffing for Database Manag...
SMACT Works
 
CIFDAQ'S Market Insight: BTC to ETH money in motion
CIFDAQ
 
Accelerating Oracle Database 23ai Troubleshooting with Oracle AHF Fleet Insig...
Sandesh Rao
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
Google’s NotebookLM Unveils Video Overviews
SOFTTECHHUB
 
Unlocking the Future- AI Agents Meet Oracle Database 23ai - AIOUG Yatra 2025.pdf
Sandesh Rao
 
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
CIFDAQ
 
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
Make GenAI investments go further with the Dell AI Factory - Infographic
Principled Technologies
 
Software Development Company | KodekX
KodekX
 
Google I/O Extended 2025 Baku - all ppts
HusseinMalikMammadli
 

CodeIgniter Class Reference

  • 1. CodeIgniter Class Reference Jamshid Hashimi Trainer, Cresco Solution http://www.jamshidhashimi.com [email protected] @jamshidhashimi ajamshidhashimi Afghanistan Workforce Development Program
  • 2. Agenda • Database Class • Calendar Class • Config Class • Email Class • File Uploading Class • Form Validation Class
  • 3. Database Class • CodeIgniter comes with a full-featured and very fast abstracted database class that supports both traditional structures and Active Record patterns. The database functions offer clear, simple syntax. • Usage Examples $this->load->database(); $DB1 = $this->load->database('group_one', TRUE); $DB2 = $this->load->database('group_two', TRUE);
  • 4. Database Class • Configuration $active_group = 'default'; $active_record = TRUE; $db['default']['hostname'] = 'localhost'; $db['default']['username'] = 'root'; $db['default']['password'] = ''; $db['default']['database'] = 'sakila'; $db['default']['dbdriver'] = 'mysql'; $db['default']['dbprefix'] = ''; $db['default']['pconnect'] = TRUE; $db['default']['db_debug'] = TRUE; $db['default']['cache_on'] = FALSE; $db['default']['cachedir'] = ''; $db['default']['char_set'] = 'utf8'; $db['default']['dbcollat'] = 'utf8_general_ci'; $db['default']['swap_pre'] = ''; $db['default']['autoinit'] = TRUE; $db['default']['stricton'] = FALSE;
  • 5. Database Class • Standard Query • Result $query = $this->db->query('SELECT name, title, email FROM my_table'); $query->result() //Object $query->result_array() //Array
  • 6. Database Class • Testing Result • Single Result if ($query->num_rows() > 0) $query = $this->db->query('SELECT name FROM my_table LIMIT 1'); $row1 = $query->row(); $row2 = $query->row_array(); echo $row1->name; echo $row2[‘name’];
  • 7. Database Class • Affected Rows $sql = "INSERT INTO mytable (title, name) VALUES (".$this->db->escape($title).", ".$this- >db->escape($name).")"; $this->db->query($sql); echo $this->db->affected_rows();
  • 8. Database Class • Query Helper Functions $this->db->insert_id(); $this->db->affected_rows(); $this->db->count_all(); $this->db->platform(); $this->db->version(); $this->db->last_query();
  • 9. Database Class • Active Record – Selecting Data • Selecting Data – LIMIT $query = $this->db->get('mytable'); // Produces: SELECT * FROM mytable $query = $this->db->get('mytable', 10, 20); // Produces: SELECT * FROM mytable LIMIT 20, 10
  • 10. Database Class • Selecting Data – Result • get_where() $query = $this->db->get('mytable'); foreach ($query->result() as $row) { echo $row->title; } $query = $this->db->get_where('mytable', array('id' => $id), $limit, $offset);
  • 11. Database Class • $this->db->select(); • $this->db->select_max(); • $this->db->select_min(); • $this->db->select_avg(); • $this->db->select_sum(); • $this->db->from(); • $this->db->where(); • $this->db->join();
  • 12. Database Class • $this->db->or_where(); • $this->db->where_in(); • $this->db->or_where_in(); • $this->db->where_not_in(); • $this->db->or_where_not_in(); • $this->db->like(); • $this->db->or_like(); • $this->db->not_like(); • $this->db->or_not_like();
  • 13. Database Class • $this->db->group_by(); • $this->db->distinct(); • $this->db->having(); • $this->db->or_having(); • $this->db->order_by();
  • 14. Database Class • Inserting Data – $this->db->insert(); $data = array( 'title' => 'My title' , 'name' => 'My Name' , 'date' => 'My date' ); $this->db->insert('mytable', $data); // Produces: INSERT INTO mytable (title, name, date) VALUES ('My title', 'My name', 'My date')
  • 15. Database Class • Inserting Data – $this->db->insert_batch(); $data = array( array( 'title' => 'My title' , 'name' => 'My Name' , 'date' => 'My date' ), array( 'title' => 'Another title' , 'name' => 'Another Name' , 'date' => 'Another date' ) ); $this->db->insert_batch('mytable', $data);
  • 16. Database Class • Updating Data – $this->db->update(); $data = array( 'title' => $title, 'name' => $name, 'date' => $date ); $this->db->where('id', $id); $this->db->update('mytable', $data);
  • 17. Database Class • Updating Data – $this->db->update_batch(); $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 2' ) ); $this->db->update_batch('mytable', $data, 'title');
  • 18. Database Class • Deleting Data – $this->db->delete(); – $this->db->truncate(); • Method Chaining $this->db->where('id', $id); $this->db->delete('mytable');
  • 19. DEMO
  • 20. Calendar Class • The Calendar class enables you to dynamically create calendars. Your calendars can be formatted through the use of a calendar template, allowing 100% control over every aspect of its design. In addition, you can pass data to your calendar cells. echo $this->calendar->generate(); echo $this->calendar->generate(2006, 6);
  • 21. DEMO
  • 22. Config Class • The Config class provides a means to retrieve configuration preferences. $this->config->item('item name'); $this->config->set_item('item_name', 'item_value');
  • 23. DEMO
  • 24. Email Class • Multiple Protocols: Mail, Sendmail, and SMTP • Multiple recipients • CC and BCCs • HTML or Plaintext email • Attachments • Word wrapping • Priorities • BCC Batch Mode, enabling large email lists to be broken into small BCC batches. • Email Debugging tools
  • 26. Email Class $this->load->library('email'); $this->email->from('[email protected]', 'Your Name'); $this->email->to('[email protected]'); $this->email->cc('[email protected]'); $this->email->bcc('[email protected]'); $this->email->subject('Email Test'); $this->email->message('Testing the email class.'); $this->email->send(); echo $this->email->print_debugger();
  • 27. Email Class • Send email with Gmail $this->load->library('email'); $config = Array( 'protocol' => 'smtp', 'smtp_host' => 'ssl://smtp.googlemail.com', 'smtp_port' => 465, 'smtp_user' => '[email protected]', 'smtp_pass' => 'yourpassword', );
  • 28. Email Class • Initialize Configuration $config['protocol'] = 'sendmail'; $config['mailpath'] = '/usr/sbin/sendmail'; $config['charset'] = 'iso-8859-1'; $config['wordwrap'] = TRUE; $this->email->initialize($config);
  • 30. File Upload Class • CodeIgniter's File Uploading Class permits files to be uploaded. You can set various preferences, restricting the type and size of the files. $this->upload->do_upload(); $this->upload->display_errors(); $this->upload->data();
  • 31. File Upload Class • Initializing Configurations $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload', $config);
  • 32. DEMO
  • 33. Form Validation Class • CodeIgniter provides a comprehensive form validation and data prepping class that helps minimize the amount of code you'll write. <?php echo validation_errors(); ?> $this->form_validation->run()
  • 35. DEMO

Editor's Notes

  • #13: $this-&gt;db-&gt;like(‘title’,’match’,’after’);$this-&gt;db-&gt;like(‘title’,’match’,’before’);$this-&gt;db-&gt;like(‘title’,’match’,’both’);$this-&gt;db-&gt;like(‘title’,’match’,’none’);
  • #14: $this-&gt;db-&gt;order_by(&apos;title desc, name asc&apos;);
  • #32: Max sizes in KB