PHP Classes

How to Learn PHP Web Applications Using the Package PHP CodeIgniter Tips Tricks: Collection of tips and examples to use CodeIgniter

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2025-05-01 (6 days ago) RSS 2.0 feedNot yet rated by the usersTotal: Not yet counted Not yet ranked
Version License PHP version Categories
php-codeigniter-tips 1.0.0BSD License5PHP 5, Libraries
Description 

Author

This package provides a collection of tips and examples to use CodeIgniter.

It provides a set of text documents, PHP, JavaScript and SQL code example scripts to help developers that want to use this framework to learn from these files.

Currently, it provides tips about using CodeIgniter for:

- Sending email

- Form processing

- Template processing

- Database access

- Image processing

- Facebook integration

- Date and time manipulation

- PDF processing

- Google Search integration

- Mac OS X integration

- Windows integration

Picture of Kabir Hossain
  Performance   Level  
Innovation award
Innovation award
Nominee: 1x

 

Instructions

Example

<?php
//
// Codeigniter native SESSION
//
//Inside config.php there is a option which is default to use cookies:

$config['sess_driver'] = 'cookie';

//Description

//'sess_driver'= the driver to load: cookie (Classic), native (PHP sessions),

//So it looks like you could change this to use native PHP sessions.


//codeigniter get database from enywhere
   
$ci=& get_instance();
       
$ci->load->database();

       
$sql = "select * from table";
       
$query = $ci->db->query($sql);
       
$row = $query->result();
//
// resize image
//
function do_resize() {
   
$filename = $this->input->post('new_val');
   
$source_path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/avatar/tmp/' . $filename;
   
$target_path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/avatar/';
   
$config_manip = array(
       
'image_library' => 'gd2',
       
'source_image' => $source_path,
       
'new_image' => $target_path,
       
'maintain_ratio' => TRUE,
       
'create_thumb' => TRUE,
       
'thumb_marker' => '_thumb',
       
'width' => 150,
       
'height' => 150
   
);
   
$this->load->library('image_lib', $config_manip);
    if (!
$this->image_lib->resize()) {
        echo
$this->image_lib->display_errors();
    }
   
// clear //
   
$this->image_lib->clear();
}


// Stored in an array with this prototype: $this->config['blog_settings'] = $config
$this->config->load('blog_settings', TRUE);
//To retrieve an item from your config file, use the following function:
$this->config->item('item name');

//Where item name is the $config array index you want to retrieve. For example, to fetch your language choice you'll do this:
$lang = $this->config->item('language');

//The function returns FALSE (boolean) if the item you are trying to fetch does not exist.

//The function returns FALSE (boolean) if the item you are trying to fetch does not exist.

//If you are using the second parameter of the $this->config->load function in order to assign your //config items to a specific index you can retrieve it by specifying the index name in the second //parameter of the $this->config->item() function. Example:
// Loads a config file named blog_settings.php and assigns it to an index named "blog_settings"
$this->config->load('blog_settings', TRUE);

// Retrieve a config item named site_name contained within the blog_settings array
$site_name = $this->config->item('site_name', 'blog_settings');

// An alternate way to specify the same item:
$blog_config = $this->config->item('blog_settings');
$site_name = $blog_config['site_name'];
//manual for this
//http://ellislab.com/codeigniter/user-guide/libraries/config.html

// AUTO LOAD LIBRARY CONFIGURATION
//If there is a config/libraryname.php file, it will be automatically loaded, just before library instanciation.

//(so, beware of name conflicts with CI's config files)


//Side note: this autoloading is disabled if you pass an array as the 2nd argument:

$this->load->library('thelibrary', array('param1' => 'value1'));

// valid a email in codeigniter
function valid_email($str) {
        return (!
preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE;
    }
   

// codeingiter add class for form element if It's not validated
   
?>
<input name="your_field_name" class="control-group <?php if (form_error('your_field_name')) echo ' class="error"'; ?>">
<?php
// UPLOAD TWO FILES WITH DIFFERENCE PATHS
//// this is for form field 1 which is an image....
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->upload->initialize($config);
$this->upload->do_upload($fieild_1);

// this is for form field 2 which is a pdf
$config['upload_path'] = './pdfs/';
$config['allowed_types'] = 'pdf';
$config['max_size'] = '100';
$this->upload->initialize($config);
$this->upload->do_upload($fieild_2);

//UPLOAD MULTIPAL FILES
function upload_multipal_files() {
   
$config['upload_path'] = 'upload/Main_category_product/';
   
$path = $config['upload_path'];
   
$config['allowed_types'] = 'gif|jpg|jpeg|png';
   
$config['max_size'] = '1024';
   
$config['max_width'] = '1920';
   
$config['max_height'] = '1280';
   
$this->load->library('upload');

    foreach (
$_FILES as $key => $value) {


        if (!empty(
$key['name'])) {

           
$this->upload->initialize($config);
            if (!
$this->upload->do_upload($key)) {

               
$errors = $this->upload->display_errors();


               
flashMsg($errors);
            } else {
               
// Code After Files Upload Success GOES HERE
           
}
        }
    }
}


Details

Codeigniter, PHP tips & tricks for developer

This is a list of tips trick & guide for these people want to learn codeigntier, php and web development 1. [Codeigniter Input for handle PUT & DELETE][1]

Codeigniter JOIN:

$this->db->select('*');
$this->db->from('TableA AS A');// I use aliasing make joins easier
$this->db->join('TableC AS C', 'A.ID = C.TableAId', 'INNER');
$this->db->join('TableB AS B', 'B.ID = C.TableBId', 'INNER');
$result = $this->db->get();

CI update data with update method without using other methods where, limit ...

$CI->db->update('allocation_tabs', $tab_data, array('id' => $tab_id), 1);

CI get data by get_where

    $tab_detail = $CI->db->get_where('table_name', array('id' => $_id), 1)->row();

CodeIgniter plugin for Sublime Text

https://sublime.wbond.net/packages/CodeIgniter%20Snippets http://stackoverflow.com/questions/16235706/sublime-3-set-key-map-for-function-goto-definition

Donate [1]:https://gist.github.com/phplaw/6305193


  Files folder image Files (115)  
File Role Description
Files folder imagecodeigniter (18 files)
Files folder imagefb (3 files)
Files folder imagejavascript (16 files, 2 directories)
Files folder imageMySql (5 files)
Files folder imagenodejs (5 files)
Files folder imagephp (15 files)
Accessible without login HTML file 404.html Doc. Documentation
Accessible without login Plain text file centos_tip_trick.md Data Auxiliary data
Plain text file ci_input_PUT-DELETE Class Class source
Accessible without login Plain text file CSS_TIP_TRICK.MD Data Auxiliary data
Accessible without login Plain text file DateWiseQuery-practicing.sql Data Auxiliary data
Accessible without login Plain text file development_resource.md Data Auxiliary data
Accessible without login Plain text file dompdf_remote_file_config.md Data Auxiliary data
Accessible without login HTML file dom_pdf_header.html Doc. Documentation
Accessible without login Plain text file drupal.php Aux. Configuration script
Accessible without login Plain text file drupal_tips.php Aux. Configuration script
Accessible without login Plain text file facebook_ip.txt Doc. Documentation
Accessible without login Plain text file font_face_example.css Data Auxiliary data
Accessible without login Plain text file funny.txt Doc. Documentation
Accessible without login Plain text file google_search.php Aux. Configuration script
Accessible without login Plain text file htaccess_tips_trick.txt Doc. Documentation
Accessible without login Plain text file jquery_placeholder_fallback.js Data Auxiliary data
Accessible without login Plain text file jquery_scoll.md Data Auxiliary data
Plain text file jsmin.php Class Class source
Accessible without login Plain text file links Data Auxiliary data
Accessible without login Plain text file mac-os_tips_and_tricks.txt Doc. Documentation
Accessible without login Plain text file mac_osx_tree_command.md Data Auxiliary data
Accessible without login Plain text file mysql_foreign_key.php Aux. Configuration script
Accessible without login Plain text file MySQL_tips_tricks.sql Data Auxiliary data
Plain text file netbeans_ci_autocomplete.php Class Class source
Accessible without login Plain text file PHP functions.php Aux. Configuration script
Accessible without login Plain text file project_example.txt Doc. Documentation
Accessible without login Plain text file README.md Doc. Documentation
Accessible without login Plain text file sublime_text2_tips_tricks.txt Doc. Documentation
Accessible without login Plain text file text_mate_tip.yml Data Auxiliary data
Accessible without login Plain text file wamp-add-more-php-version.md Data Auxiliary data
Accessible without login Plain text file windows_tips_tricks.yml Data Auxiliary data
Accessible without login Plain text file zend2 Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads  
 100%
Total:0
This week:0