Last Updated | | Ratings | | Unique User Downloads | | Download Rankings |
2025-05-01 (6 days ago)  | | Not yet rated by the users | | Total: Not yet counted | | Not yet ranked |
|
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 | |
 |
|
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
[1]:https://gist.github.com/phplaw/6305193
|
Applications that use this package |
|
No pages of applications that use this class were specified.
If you know an application of this package, send a message to the author to add a link here.