Showing posts with label Web Developer. Show all posts
Showing posts with label Web Developer. Show all posts

Thursday, November 20, 2014

simple generator CRUD database operation using Grocery CRUD

simple generator CRUD database operation using Grocery CRUD

Hi guys ..... this is my first tutorial post about using Grocery CRUD in CodeIgniter. I used library Grocery CRUD for  CRUD in every my project . I think the library is very complete with all the features it has. In fact, this library supports AJAX. How use it was very easy and I guarantee when you've tried would definitely hooked with the easy. In addition to supporting its AJAX to CRUD transactions, Grocery CRUD also supports the relation of each table in the database with a very simple configuration. It is true to say if we only took less than 5 minutes to create a CRUD from a database table. Wow ... very different from when we make CRUD manually.

In addition Grocery Crud also always developed by the developer and this library is Open Source. Okey .. we just discussed for using grocery CRUD tutorial on CodeIgniter.

The first step
If you do not have it you can download the library Grocery CRUD at www.grocerycrud.com. 

Then if you have not got a CodeIgniter can download www.codeigniter.com
 

Step two
Once you have successfully downloaded, please be sure could've used CodeIgniter and Prepare a database.

Welcome Page Codeigniter 
And this is for create your dummy database


CREATE TABLE IF NOT EXISTS `employees` (
  `employeeNumber` int(11) NOT NULL AUTO_INCREMENT,
  `lastName` varchar(50) NOT NULL,
  `firstName` varchar(50) NOT NULL,
  `extension` varchar(10) NOT NULL,
  `email` varchar(100) NOT NULL,
  `officeCode` varchar(10) NOT NULL,
  `file_url` varchar(250) CHARACTER SET utf8 NOT NULL,
  `jobTitle` varchar(50) NOT NULL,
  PRIMARY KEY (`employeeNumber`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1703 ;
 
 
INSERT INTO `employees` (`employeeNumber`, `lastName`, `firstName`, `extension`, `email`, `officeCode`, `file_url`, `jobTitle`) VALUES
(1002, 'Murphy', 'Diane', 'x5800', 'dmurphy@classicmodelcars.com', '1', '', 'President'),
(1056, 'Patterson', 'Mary', 'x4611', 'mpatterso@classicmodelcars.com', '1', '', 'VP Sales'),
(1076, 'Firrelli', 'Jeff', 'x9273', 'jfirrelli@classicmodelcars.com', '1', '', 'VP Marketing'),
(1088, 'Patterson', 'William', 'x4871', 'wpatterson@classicmodelcars.com', '6', '', 'Sales Manager (APAC)'),
(1102, 'Bondur', 'Gerard', 'x5408', 'gbondur@classicmodelcars.com', '4', 'pdftest.pdf', 'Sale Manager (EMEA)'),
(1143, 'Bow', 'Anthony', 'x5428', 'abow@classicmodelcars.com', '1', '', 'Sales Manager (NA)'),
(1165, 'Jennings', 'Leslie', 'x3291', 'ljennings@classicmodelcars.com', '1', '', 'Sales Rep'),
(1166, 'Thompson', 'Leslie', 'x4065', 'lthompson@classicmodelcars.com', '1', '', 'Sales Rep'),
(1188, 'Firrelli', 'Julie', 'x2173', 'jfirrelli@classicmodelcars.com', '2', 'test-2.pdf', 'Sales Rep'),
(1216, 'Patterson', 'Steve', 'x4334', 'spatterson@classicmodelcars.com', '2', '', 'Sales Rep'),
(1286, 'Tseng', 'Foon Yue', 'x2248', 'ftseng@classicmodelcars.com', '3', '', 'Sales Rep'),
(1323, 'Vanauf', 'George', 'x4102', 'gvanauf@classicmodelcars.com', '3', '', 'Sales Rep'),
(1337, 'Bondur', 'Loui', 'x6493', 'lbondur@classicmodelcars.com', '4', '', 'Sales Rep'),
(1370, 'Hernandez', 'Gerard', 'x2028', 'ghernande@classicmodelcars.com', '4', '', 'Sales Rep'),
(1401, 'Castillo', 'Pamela', 'x2759', 'pcastillo@classicmodelcars.com', '4', '', 'Sales Rep'),
(1501, 'Bott', 'Larry', 'x2311', 'lbott@classicmodelcars.com', '7', '', 'Sales Rep'),
(1504, 'Jones', 'Barry', 'x102', 'bjones@classicmodelcars.com', '7', '', 'Sales Rep'),
(1611, 'Fixter', 'Andy', 'x101', 'afixter@classicmodelcars.com', '6', '', 'Sales Rep'),
(1612, 'Marsh', 'Peter', 'x102', 'pmarsh@classicmodelcars.com', '6', '', 'Sales Rep'),
(1619, 'King', 'Tom', 'x103', 'tking@classicmodelcars.com', '6', '', 'Sales Rep'),
(1621, 'Nishi', 'Mami', 'x101', 'mnishi@classicmodelcars.com', '5', '', 'Sales Rep'),
(1625, 'Kato', 'Yoshimi', 'x102', 'ykato@classicmodelcars.com', '5', '', 'Sales Rep'),
(1702, 'Gerard', 'Martin', 'x2312', 'mgerard@classicmodelcars.com', '4', '', 'Sales Rep');
 

So make sure that you have your database settings there. For example:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * CodeIgniter
 *
 * An open source application development framework for PHP 5.1.6 or newer
... mpla mpla mpla
*/
 
$active_group = 'default';
$active_record = TRUE;
 
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = ''; //enter your database username
$db['default']['password'] = ''; //enter your database password
$db['default']['database'] = ''; //enter your database Name
$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;
$db['default']['failover'] = array();
 
/* End of file database.php */
/* Location: ./application/config/database.php */
 

The third step

Let's create our first controller. Let's name our first controller Main. So to do that, you will go to your_project/application /controllers/ and add the main.php , that will look like this:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Main extends CI_Controller {
 
    function __construct()
    {
        parent::__construct();
 
        $this->load->database();
 
    }
 
    public function index()
    {
        echo "<h1>Welcome to the world of Codeigniter</h1>";//Just an example to ensure that we get into the function
        die();
    }
}
 
/* End of file main.php */
/* Location: ./application/controllers/main.php */


The fourth step
To make sure that everything works fine, you have to go to http://localhost/your_project/index.php/main and see the message:  
 Welcome to the world of Codeigniter. 

The fifth step
Make sure that you have installed grocery CRUD correctly at your project by adding all the files and folders to your project. After the end of your installation, your project will have to look similar to this structure:

website_folder/
–––– application/
–––––––– config/
–––––––––––– autoload.php
–––––––––––– ...
–––––––––––– doctypes.php
–––––––––––– foreign_chars.php
–––––––––––– grocery_crud.php
–––––––––––– ...
–––––––– controllers/
–––––––––––– examples.php
–––––––––––– index.html
–––––––––––– welcome.php
–––––––– libraries/
–––––––––––– grocery_crud.php
–––––––––––– index.html
–––––––– models/
–––––––––––– grocery_crud_model.php
–––––––––––– index.html
–––––––– views/
–––––––––––– example.php
–––––––––––– index.html
–––––––––––– welcome_message.php
–––– assets/
–––––––– grocery_crud/
–––––––––––– css/
–––––––––––– js/
–––––––––––– texteditor/
–––––––––––– themes/
–––––––– uploads/
–––––––– index.html
–––– system/
–––– user_guide/
–––– change_log.txt
–––– example_database.sql
–––– index.php
–––– licence-grocery-crud.txt
–––– license.txt 

Step six
Let's go to our controller and add some stuff to make grocery CRUD work. Add the method employees like the below example:

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Main extends CI_Controller {
 
    function __construct()
    {
        parent::__construct();
 
        /* Standard Libraries of codeigniter are required */
        $this->load->database();
        $this->load->helper('url');
        /* ------------------ */ 
 
        $this->load->library('grocery_CRUD');
 
    }
 
    public function index()
    {
        echo "<h1>Welcome to the world of Codeigniter</h1>";//Just an example to ensure that we get into the function
        die();
    }
 
    public function employees()
    {
        $this->grocery_crud->set_table('employees');
        $output = $this->grocery_crud->render();
 
        echo "<pre>";
        print_r($output);
        echo "</pre>";
        die();
    }
}
 
/* End of file main.php */
/* Location: ./application/controllers/main.php */

If everything goes well and you don't have any errors or exceptions you will go to: http://localhost/your_project/index.php/main/employees and see the below result, then everything works correctly :


stdClass Object
(
    [output] => Your output will appear here....
    [js_files] => Array
        (
            [763b4d272e158bdb8ed5a12a1824c94f494954bd] => http://grocery_crud/public/grocery_crud/themes/datatables/js/jquery-1.6.2.min.js
            [0b677f3fc6fb25b4baf39eb144222116c5b60254] => http://grocery_crud/public/grocery_crud/themes/flexigrid/js/cookies.js
            [ec3ae62b8d5838972e858fe54447bd4bd8d79f88] => http://grocery_crud/public/grocery_crud/themes/flexigrid/js/flexigrid.js
            [2c0ff56d0cbc6f80a5ef9c770d478f0e00c3170d] => http://grocery_crud/public/grocery_crud/themes/flexigrid/js/jquery.form.js
            [474495ff1e895eab81fb8afba4db9b06c15b19af] => http://grocery_crud/public/grocery_crud/themes/flexigrid/js/jquery.numeric.js
        )
 
    [css_files] => Array
        (
            [732b03aa54d124f062757b71e5560acdc5632ba6] => http://grocery_crud/public/grocery_crud/themes/flexigrid/css/flexigrid.css
        )
 
)
 
Important Note: Please make sure that you don't have grocery CRUD to the index function of your controller as it is a known issue that it will not work on index. Just move it to another method. For example "employees" or something else except index.

The seventh step.
Now let's create our view. The results that we have seen we can use them to have grocery CRUD to our project. We just need a view to do it. So a view will look like this:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
 
<?php 
foreach($css_files as $file): ?>
    <link type="text/css" rel="stylesheet" href="<?php echo $file; ?>" />
 
<?php endforeach; ?>
<?php foreach($js_files as $file): ?>
 
    <script src="<?php echo $file; ?>"></script>
<?php endforeach; ?>
 
<style type='text/css'>
body
{
    font-family: Arial;
    font-size: 14px;
}
a {
    color: blue;
    text-decoration: none;
    font-size: 14px;
}
a:hover
{
    text-decoration: underline;
}
</style>
</head>
<body>
<!-- Beginning header -->
    <div>
        <a href='<?php echo site_url('examples/offices_management')?>'>Offices</a> | 
        <a href='<?php echo site_url('examples/employees_management')?>'>Employees</a> |
        <a href='<?php echo site_url('examples/customers_management')?>'>Customers</a> |
        <a href='<?php echo site_url('examples/orders_management')?>'>Orders</a> |
        <a href='<?php echo site_url('examples/products_management')?>'>Products</a> | 
        <a href='<?php echo site_url('examples/film_management')?>'>Films</a>
 
    </div>
<!-- End of header-->
    <div style='height:20px;'></div>  
    <div>
        <?php echo $output; ?>
 
    </div>
<!-- Beginning footer -->
<div>Footer</div>
<!-- End of Footer -->
</body>
</html>
 
 So let's save this file into: your_project/application/views/our_template.php and go to our controller and add some more stuff.

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Main extends CI_Controller {
 
    function __construct()
    {
        parent::__construct();
 
        /* Standard Libraries of codeigniter are required */
        $this->load->database();
        $this->load->helper('url');
        /* ------------------ */ 
 
        $this->load->library('grocery_CRUD');
 
    }
 
    public function index()
    {
        echo "<h1>Welcome to the world of Codeigniter</h1>";//Just an example to ensure that we get into the function
                die();
    }
 
    public function employees()
    {
        $this->grocery_crud->set_table('employees');
        $output = $this->grocery_crud->render();
 
        $this->_example_output($output);        
    }
 
    function _example_output($output = null)
 
    {
        $this->load->view('our_template.php',$output);    
    }
}
 
/* End of file main.php */
/* Location: ./application/controllers/main.php */


Now go to http://localhost/your_project/index.php/main/employees and you will see a result like this:
Employees example

Very easy and simple to make a crud. Now it's time to use on any of your projects. You can see the documentation from Grocery CRUD complete in its web. Hopefully my tutorial can help you in learning CRUD.

learn more about codeigniter follow this link

Wednesday, November 19, 2014

Grocery CRUD : Best Library CRUD for Code Igniter

Grocery CRUD : Best Library CRUD for Code Igniter

Grocery CRUD : Best Library CRUD for Code Igniter
blogdephp
CRUD is Create, Read, Update and Delete most important thing that we in the management of data in a database. This time I will discuss Grocery CRUD. Why?. Because Grocery Crud CRUD library is one of the best for CodeIginter Framework. Grocery CRUD is an open source library that makes a developer's life Easier. Just few lines of code and you can create a stable full CRUD with nice views. A completely automatic system that even a newbie in PHP can work with.


Like the proverbial Grocery Crud

Create a full stable CRUD in just 30 seconds

Grocery CRUD has a lot of advantages over other CRUD library.
The simplest example. Just one line of code!
Just 1 line of code and you will have a full CRUD. In this example I set the table name (offices) and I get the default CRUD with add-edit and delete (create-update-delete) All the views are ready and you don't need anything else...
Do not worry as they are callbacks almost everywhere
Everything is automated but you are free to change almost everything. You can customize columns, fields and all the operations with a quick callback. There are several examples to understand how callbacks work.
Everything that you are looking for is here... all in a box
View all the CRUD functions and descriptions for each function in one page. Every method and function that you can use for grocery CRUD you can easily find it at the API that also includes examples.
Why do we have to use Grocery CRUD?
Grocery CRUD is not just another CRUD generator or just another codeigniter grid generator. It is a totally different idea and... more simple idea! With few simple PHP lines of code you can have all the functionality that you need to create your CRUD. So this means you don't have to copy the same Javascripts,CSS, views,models,vaildation rules,html code, grid, upload functionality ... e.t.c . again and again. To create again a CRUD for a different table you will just need simple PHP lines of code.

The good part is that you don't even have to change the CSS to make it more user friendly. Grocery CRUD is ready for the production mode with all the required security and views.

Grocery CRUD is an automatic CRUD generator and it can cover almost all your needs for a CRUD system (simple or complex one) as it has many features and still keep going.

Some of the main features of grocery CRUD are:
  • datagrid listing with paging, sorting, searching by field and search for all with ajax (flexigrid theme) or instant javascript scripting (datatables theme)
  • automatic creation of inputs by field type. Till now the field types that auto-generate different inputs are: integer, string, text, date, datetime, set, enum, true_false(0 or 1), hidden, password and readonly
  • database relation 1-1 , 1-n and n-n , automatically with just one line of code
  • changing themes easlily, so far there are two themes , datatables and flexigrid
  • validation form with client side validation and server side validation
  • adding your own validation rules
  • flexibility to choose columns and fields that you want to add to your table
  • unset operation like unset add, edit or delete
  • callbacks almost everywhere to do your own customizations
  • changing the auto generate field type, for example a text field can transform easily to date field
  • want to do something more complex? In grocery CRUD you can add your own model by extending the basic model
  • works fine with all the modern browsers, such as: Mozilla Firefox, Google Chrome,Opera, Safari, Internet Explorer 8 or later and works fine for all the modern OS systems such as Windows, Linux, MACOS
  • mobile compatible, works fine with the default browsers of Android , Windows and Apple mobiles
  • multilingual functionality. Till now translated to 25 languages:
    • Afrikaans, Arabic, Bulgarian, Catalan, Chinese, Danish, Dutch, English, French, German, Greek, Indonesian, Italian, Japanese, Persian, Polish, pt-BR.portuguese, pt-PT.portuguese, Romanian, Russian, Spanish, Thai, Turkish, Ukrainian, Vietnamese.
There are so many advantages of grocey CRUD yes. Hope can add to your knowledge. Very easy to use Grocery CRUD in CodeIgniter. We do not need hard make CRUD Manual

You can learn more about CI at jembatankali.com
Best Text Editor For Web Designer & Web Developers

Best Text Editor For Web Designer & Web Developers

Best Text Editor For Web Designer & Web Developers
howtogeek
hi guys ... today I will discuss about the text editor. for those who do not know what text editor. Text editor is a type of program used for editing plain text files.

Text editors are Often-provided with operating systems and software development packages, and can be used to change, eg, configuration files, documentation files, programming language source code. (source: wikipedia)

Text Editor is different from a word processor such as Microsoft Word, WordPerfect and OpenOffice.org, as the text editor does not set the format of the document or other features that are commonly used for desktop publishing.

Text editor can be used to change configuration files and programming language source code. Her use a plain text editor for programmers to write the text and for the management of code they wrote. plain text editor supports a variety of programming languages such as HTML, PHP, C #, C ++, Python, CSS, etc.

Many types of text editors that exist now but are described only text editor that is currently widely used by developers.

UltraEdit
With more than 2 million users worldwide users, this is one of the most powerful text editors that have the flexibility and ease of use. Can be used for HTML, PHP, Javascript, Perl, C, C ++, and many more types of programming languages. This editor is able to work as a simple text editor or a hex editor.

Bluefish
Bluefish is one of the most popular text editor and best development today. This lightweight text editor that supports the development of HTML, XHTML, CSS, XML, PHP, C, JavaScript, Java, SQL, Perl, ColdFusion, JSP, Python, Ruby and Shell. Released under the GNU GPL license, and the development of open source projects can be run on most POSIX compatible OS including Linux, FreeBSD, MacOS-X, OpenBSD and Solaris.

Notepad ++
Notepad ++ can be called an improvement from the original Notepad which has almost every feature that can be embedded in a text editor. Free source code editor supporting many languages such as C, C ++, C #, Java, HTML, Javascript, CSS, PHP, Perl and many more. The features of this editor diataranya: Auto Completion, Multiview, MultiDocument, Brace and Indent, Drag and Drop, Syntac Coloring and many more. Editor popularity is evident by the number of downloads to more than 13 copies.

PSPad
PSPad is a freeware editor for Windows operating system that is simple and sophisticated. This editor has a feature embedded spell checker, syntax highlighting and supports many file types and languages. Easy to install and easy to use. PSPad has a HEX editor, Project support, FTP Client, Macro Recorder, File Search / replace Options, Code Explorer and much more.

vim
Vim is a text editor that is very powerful and popular. This editor is very flexible and easily configured for efficient text editing. An improved version of the vi editor in UNIX systems. This editor can be used for wide variety of programming languages to a simple text editor called evim or Easy Vim. Vim does not provide WYSIWYG editing, but it works very well with TeX. Modern and sophisticated version of Vim is Cream, available for Windows, GNU / Linux and Free BSD.



Notepad 2
The text editor is fast and lightweight. Notepad 2 has many excellent features, such as syntax highlighting, HTML, XML, PHP, CSS, VBScript, Resourve Script, C, C ++, Python, Bath Files, Apache Files and much more. Having the ability to drag and drop tests. Other features include a regular expression search, shortcuts, auto indent, line markers and other lonh.

Komodo Edit
Komodo IDE is an award-winning text editor, and has a very good ability, free and open source. Features autocomplete, calltips, syntax coloring, syntax checking, Vi emulation and much more. Editor works on almost all platforms eg Linux or Mac or Windows. Komodo Edit supports most programming languages like PHP, Ruby, Perl, HTML and template languages like RHTML, Django and many more.


TextPad 
 Designed to provide high performance. TextPad can edit large files up to 32-bit virtual memory limit. This is a basic text editor with a user interfce multi language: English, German, Italian, Polish, Portuguese, and Spanish. Multiple files can be edited simultaneously and a spell checker with dictionaries in 10 languages is one of its. The other is the shift, block indentation, transposing words and lines, in addition to the normal cut, copy and paste
 

Sublime Text (Cross Platform)

This one is a favorite text editor writer, other than it looks simple and beautiful fiturnyapun very diverse. Sublime text is a text-editor is really a text editor :), meaning the entire application configuration is done by editing the configuration file another case with notepad ++ which uses a GUI for the application settings.
Sublime text can also be strengthened with the Package Control (same as PlugIn), you can install Zencoding here.
Sublime text is available for various operating systems ranging from Windows, Linux, and MacOSX at a price of $ 59 for a single license.

it is part of a wide range of existing text editor. everyone has the style and taste of each to choose a text editor. but during this time that I used to use is notepad ++, sublime and brackets. If anyone knows brackets can not open my another article about Brackets modern text editor