Tuesday, November 13, 2012

Plugins, Library, Helpers In Codeigniter



1. Plugin

Codeigniter plugin consists of a single function. It is almost the same as the helper, but the number of helper functions on more than one.

Plugins are stored in a folder in codeigniter system / plugins. We can also mmebuat plugin itself and we save the folder application / plugins.

For meloadnya we run the function:

$ this-> load-> plugin ('name');

2. Library

Library on Codeigniter contained in the folder system / libraries.
The function is used to call the library are:

$ this-> load-> library ('name');

3.Helpers

              Helpers is a collection of functions that can do specific tasks. To be able to use the helper.

Helper files contained in the folder system / application / helpers or / system / helpers.

To call a helper function used is:

      $ this-> load-> helper ('name');

            If we want to load a lot of helpers we can use an array containing the names of helpers that we want to load. How to use dalah such as by calling the PHP function call.

Monday, November 12, 2012

Create Quick Search with PHP


        In this discussion we will discuss the scripts used to make a quick search by providing key words to search

Example : Create quick search on mahasiswa  table

<form name="formku" method="get" action="">
Search : <input type="text" name="q" id="q"/> <input type="submit" value="Search"/>
</form>
<!-- menampilkan hasil pencarian -->
<?php
if(isset($_GET['q']) && $_GET['q']){
$conn = mysql_connect("localhost", "root", "");
mysql_select_db("test");
$q = $_GET['q'];
$sql = "select * from mahasiswa where nama like '%$q%' or
nim like '%$q%' or fakultas like '%$q%' or alamat like '%$q%'";
$result = mysql_query($sql);
if(mysql_num_rows($result) > 0){
       ?>
       <table>
             <tr>
                   <td>Nama</td>
                   <td>Nim</td>
                   <td>Fakultas</td>
                   <td>Alamat</td>
             </tr>
             <?php
             while($record = mysql_fetch_array($result)){?>
             <tr>
                   <td><?php echo $record['nama'];?></td>
                   <td><?php echo $record['nim'];?></td>
                   <td><?php echo $record['fakultas'];?></td>
                   <td><?php echo $record['alamat'];?></td>
             </tr>
             <?php }?>
       </table>
       <?php
}else{
       echo 'Data not found!';
}
}
?>

Saturday, November 10, 2012

Controller, Model and View in Codeigniter



1.Controller

Controller will determine an HTTP request to be handled where the controller is a class that can be called in the URL. If we call our controller then CodeIgniter will look for the controller with the controller name is what we mean and then CodeIgniter will meloadnya.

2. Model

The model is made ​​to relate class in the database. Models saved in the application / models /.
The structure of the model is:

Class extends Model {ModelName
ModelName function () {
Parent :: Model ();
}
}

To call it a model called from the controller to the function:

$ this-> load-> model ('ModelName');

3. View

View a display on a web page. Loading the view is done by the function:

$ this-> load-> view ('viewname');

In codeigniter also do call some view of the controller just by adding a call to the desired view.

Friday, November 9, 2012

Library in Codeigniter


Library which is on CodeIgniter is a class that contains a variety of methods that can be used to automatically kelita class already loaded.

Several kinds of the existing library on codeigniter is:

1. Calendaring
Library is used to create a particular calendar month or year.

2. Language
Load multiple languages ​​if the sites that we have needed.

3. FTP
It is a library that is used to transfer files to the remote server.

4. Database
Library is equipped with a variety of methods to manipulate the database.

5. Config
It is a library that contains information about the system configuration.

6. Output
Library which will automatically send the web page to the requesting browser and also for caching process.

7. Pagination
Library used to make pagination of result query our database. We can set a record that will be displayed and the display of pagination we want.

8. Form Validation
Library that is used to validate input data from form.

9. HTML Table
Library is used to generate HTML tables.

10. Input and Security
Library that is used to process the input data from the form and handle security function.

Thursday, November 8, 2012

Helper in CodeIgniter


          Helper in CodeIgniter is a collection of functions that will help make the application using CodeIgniter. Helper has a procedural.

Default helper in CodeIgniter.

1. Helper email

2. Html helper

3. Helper date

         Rules on making the helper name helpername_helper and files are stored on the directory website / system / helpers /. After making the next step is to run the helper. In order to run it we have to load first. 

How to load helper we have made are: 

1. In the autoload.php

2. Through Controller

There are two ways to load the helper in the controller:

       a. put in the constructor
       b. put in the function.

3. Inside View

Wednesday, November 7, 2012

Scaffolding In Codeigniter



Scaffolding in codeigniter is one of the features that provide a quick and extremely easy to add, edit, or delete data on database.selain advantages, scaffolding also has disadvantages in terms of security that is lacking. Less scaffolding safety lies in the secret word that is on the configuration routes.php

Directory of Scaffolding:      
Images
            Views
            Index
            Scaffolding.php
            Add.php
            Delete.php
            Detail.php
            Edit.php
            Footer.php
Header.php
Index
No_data.php
Stylesheet
View.php


Tuesday, November 6, 2012

Configuration Codeigniter


Once we managed to install Codeigniter, then the next step is to do some configuration files. Configuration is done on the folder / system / application / config /. Some of the files that should be configured are:

1. config.php

Can we change the configuration of this file is the base url used to call the browser address.

$ config ['base_url'] = "http://situsname.com";

By adjusting this configuration we do not need a complete rewrite url address us. We simply call the function base_url. If we will transfer the address on the address of another server, then we must change the base_url with default values​​:

$ config ['index_page'] = "index.php"

2. autoload.php

File is used to specify the resource that will be loaded by otoatis by Codeigniter.

$ autoload ['libraries'] = array ('database', 'session', 'pagination');
$ autoload ['helper'] = array ('url', 'file');
$ autoload ['plugin'] = array ();
$ autoload ['config'] = array ();
$ autoload ['language'] = array ();
$ autoload ['model'] = array ();

3. database.php

Is a file that contains all the database-related. In database.php file that needs to be configured are:

a. hostname
b.username
c. password
d. databasename
e. dbdriver

4. routes.php

File is used to set the remap request URL that points to a function in a controller.

Once we managed to install and configure multiple files, try to open the folder Codeigniter us. If the configuration is done right, then we will go on the welcome page.

Monday, November 5, 2012

Installation of CodeIgniter


Before  to install codeigniter we must first download.CodeIgniter is a framework a free so that we can freely download it www.codeigniter.com then select download and choose codeigniter latest version.
The steps to install Codeigniter:

1. Extract Codeigniter folder into the webserver directory. For example, if we use Xampp, then the extracted folder in htdocs folder.
2. Enable Apache and MySQL on Xampp Control Panel Application.
3. Double click on the folder and extract Codeigniter into htdocs folder. And wait until the extraction is complete.
4. Once the extract is completed we can see the folder structure of Codeigniter.
5. If we find it difficult to address the process of calling and writing then we can rename the folder Codeigniter.

File Structure in Codeigniter

In codeigniter folder there are two folders, namely System and user_guide. System contains the core of CodeIgniter while user_guide contains documentation of CodeIgniter.
Folders contained in the System folder:

1. Application
Folder is used to store program code that we created. In the application folder, there are 3 other folders
a. Models
Models a folder to store the model we make
b. controller
Controller is the folder used to store the controller
c. views
Views is a folder used to store and display tempale
Used to display the information.
2. Codeigniter, the folder containing the files you want to load the core of the framework.
3. Cache folder caching to store data from a website.
4. database
5. Helpers
6. Fonts
7. Language

Sunday, November 4, 2012

What is Codeigniter


CodeIgniter is a PHP framework that is currently popular today. CodeIgniter is an open source application framework for the MVC concept can create dynamic websites using PHP. Codeigniter easy for someone who wants to make building web applications quickly and easily than with him from the beginning, because there were already Codeigniter facility that allows to build dynamic web. Codeigniter is one of the popular mvc framework because it has benefits or advantages of another mvc framework. Codeigniter MySQL database suppport (4.1 +), MySQLi, MS SQL, Postgres, Oracle, SQLite, and ODBC.

Here are some advantages of codeigniter:
1.  a complete library of codeigniter
2. Securities great application.
3. Complete documentation and easy to learn.
4.  Using the MVC pattern that increases flexibility.
5.  Generate search engine friendly urls
6.  Getting support from codeigniter forums.
7.  Walk in PHP 4 (4.3.2 +) and 5
8.  Support with many databases.
9.  Easy to create or add a library and helper

Saturday, November 3, 2012

The Concept of MVC PHP Framework


       MVC is a pattern that aims to separate the business logic, data logic and presentation logic or simply split between design, data and processes.

The concept of MVC is the Model-View-Control, namely:

a. Model, The model was processing data related to the database interface and interaction, located in the system / applications / models /.

b. View in touch with everything that is displayed to the enduser, located in the system/applications/view/ .

c. Controller is processing user requests and return the user request in the form of View. act as penguhubung data and view. Located in the system/application/controller/
.
       One of the current popular mvc framework is Codeigniter or often abbreviated as CI.
Picture below is the structure of mvc on Codeigniter:


Friday, November 2, 2012

Function in PHP


        There are several functions that can be executed in PHP are:

1. Echo () is used to display the parameters to the screen.

2. Include () is used to invoke the name of the file to be executed.

3. Strlen () is used to calculate the length of a value that is the result of type integer.

4. Date () is used to process and display the date of the computer system.

5. Getdate () is used to generate the date and result of type array.

6. Isset () is used to return true if the variable contains data and is false if the variable is empty.

           In addition to the above functions, we can also create your own function. Suppose the function to calculate the area, circumference, volume count or the other functions we want.

Example :

<?php
function kl($p,$l)
{
$kel = 2 * ($p + $l);
return ($kel);
}

?


<?php
function ls($p,$l)
{
$luas = $p * $l;
return ($luas);
}
 
?

Execute :

kl();

ls();