Quickly Build CRM, CMS, Database Forms and backend admin application using PDO CRUD – Advanced PHP CRUD Generator Tool

Quickly Build CRM, CMS, Database Forms and backend admin application using PDO CRUD – Advanced PHP CRUD Generator Tool

In this article, we’re going to discuss PDO Crud – Advanced PHP CRUD application (Form Builder & Database Management tool). We will build a simple web application using PDO CRUD to show how PDO CRUD helps you to reduce your work significantly and helps you to make the application more efficiently in a super fast manner. PDO CRUD helps you to perform crud operation for your database tables with just a few lines of code. PDO CRUD saves your lots of time by generating forms directly from database tables automatically instead of creating it manually. You don’t need to handle the database crud operation. PDO CRUD manages all CRUD operation (create, read, update and delete) for you to more focus on the logic part of your application.  You can use PDO CRUD to develop both frontend and as well as backend.

Overview

Almost for each web application, we need to write many-many lines of codes. We need to perform insertion of data, then updating and deleting the same data, and of course, reading the data from your database tables and displaying it. For examples, if you are developing a simple school management application and you want to write code for managing the student data, you will need to do tedious job of writing code to create insert form with all fields of the student table along with database insert code, then you will need to show that data in the form of HTML table. After that, you will need to write code for update form for same fields and deletion of student data from the database table. This typically consists of 1000s of lines of code. PDO Crud script does this work by just writing 2 lines of code, saving a huge amount of time.  By writing only a few lines of code, you will be able to create forms directly from the database table, HTML table for displaying data, update, and deletion of data along with several other operations, like pagination, records per page, search, export of data, etc. PDO CRUD comes with default bootstrap (you can use without bootstrap also) and generates responsive bootstrap forms directly from the database.

Apart from normal crud operation, we often require many customization like applying conditional logic, formatting table data, making a field as an auto-suggest dropdown, etc. PDO CRUD lets you do various customization related to the database table and form data in many ways as per requirement by writing only a few lines of codes. Many javascript plugins are also added that help to perform many other tasks also. PDOCRUD has many features to ease the development process and saves your time. For example, it automatically detects the field type from the database field type, converts the underscore in spaces, capitalizes the first letter of the form field, etc to ease out the development process. 

Let’s start: How to Develop a Simple Web Application using PDOCRUD

In this article, we are going to learn how we can create backend applications using PDO CRUD. To understand the process, we will develop the simple school management application as most of the concept related to the school management are easy to understand and most of us are familiar with it. Please note that we will be developing only a few features of school management app and our focus will be more on learning PDO CRUD features. In this article, we will focus on various backend application features and in the next article, we will focus on user login management part.

Prerequisite:

Installation & Configuration:

Installation and configuration various settings is quite easy as most of the settings can be used directly. We have written a separate article on installation and configuration of the PDO CRUD. Please check it out here
http://pdocrud.com/tutorial/pdo-crud-quick-installation-configuration/

Application Development:

In this section, we will develop a complete school management application from scratch.  First, we will develop various pages where we will write code to manage the various sections of the application. In the next article, we will focus on user access management of our application.

We will be using Admin LTE theme for demo purpose, though you can use any theme. For any page of the application, we will mostly have the similar header, footer, and side menu so lets put the code of these subsections in a separate PHP file and include in our each PHP page. You can skip this part if you want.

Let’s start with managing the students’ data by creating a file named students.php. We have table name students in our database and we will write now code to perform crud operation on students table.  We will create students.php with the following PHP code.

PDO CRUD Default Operation - generating crud using 2 lines of codes
PDO CRUD Default Operation – generating crud using 2 lines of codes

Let’s run this code

Student CRUD Table generated using PDO CRUD
Student CRUD Table generated using PDO CRUD

That’s it!!!  By writing just two lines of code in a few seconds with minimal efforts, you have a complete CRUD interface and you can perform all the operation i.e. create, read, update, and delete actions on your database table.  If you would have done the same thing by writing code for forms, database operation and display of data from the table, it would have required you to write too many lines of codes and it would have been a very time-consuming job.  Apart from the default crud operations, it has many features including:

  • Search – Search records in the complete table or column wise search
  • Pagination – Shows pagination based on the no. of records per page
  • Export – Print and export data to various formats
  • Bulk delete action – Delete multiple entries by selecting using the checkbox
  • Sorting by table columns – Sort by clicking on any table column
  • Records per page – Show no. of records per page e.g. 10, 20, 50, 100

The two lines of code have generated a complete lightweight easy to use crud interface for your application. You can see the almost no effort was required to build crud for your students model. You will learn about various customization options in later sections that will help you do more tasks easily.

You can use the top right corner “Add” button to open insert form for students table and populate the students’ data.

Insert form generated using PDO CRUD
Insert form generated using PDO CRUD

As you can see, it has generated the user-friendly field names.  All fields are generated on the basis of their database type and using their name. For example, the birth date field is date type field, student address is automatically converted into textarea, gender is converted to dropdown. Not to mention the complete form is responsive and works flawlessly on various devices.  You have default four types of the button to perform database insert operation or cancel it. Once you save the entry and go back to the table, you will be able to see the student entry added on the table.

Automatic field detection and naming of field using PDO CRUD
Automatic field detection and naming of field using PDO CRUD

You can use the edit, view and delete actions buttons to perform these operations on the selected data row.  Other various tasks are already explained above like search, pagination, records per page, export.

Similarly, you can create pages for the other tables CRUD operations by writing this same two lines of code.  We are not showing demo code for each file as it’s similar to what we have shown above. You can add all these pages on the side menu.  You will say most of the big tasks related to crud operations are already completed in few mins.

CUSTOMIZATION

Now, we will discuss various customization options available using the PDO CRUD. We will try to cover as many options as possible as there are lots of customization feature available in PDO CRUD tool.

  1. Form Fields Customization: You can use various functions available in PDO CRUD to format the form fields. We will take students model as an example to show how various form fields customization works.
    1. Field Type: In students insert form, you can see that section and class fields are currently text field but it would make more sense if these fields are dropdown and users will be able to select section and class field from the dropdown list populated from section and class table. You can easily achieve this by specifying the type of field as “select” and data source that will be used to populate the field data. You will be able to get select dropdown data directly from the table “section” and “class”.
//change field type to dropdown
                $pdocrud->fieldTypes("class_id", "select");//change class_id to select dropdown
                $pdocrud->fieldTypes("section_id", "select");//change section_id to select dropdown
                $pdocrud->fieldTypes("gender", "radio");//change gender to radio button
                $pdocrud->fieldTypes("student_image", "file_new");//change student image field to file type
                //Load data of these fields from the database tables directly
                $pdocrud->fieldDataBinding("class_id", "class", "class_id", "class_name", "db");//load class data from database table "class"
                $pdocrud->fieldDataBinding("section_id", "section", "section_id", "section_name", "db");//load class data from database table "section"
                //Load data from array
                $pdocrud->fieldDataBinding("gender", array("male"=>"male","female"=>"female" ,"Other"=>"Other"), "", "","array");//add data binding using array
Changing field type using PDO CRUD

Similarly, you can define the gender as “radio” button with data source as an array containing “male” and “female”.  You can change field types as required for any field, PDO CRUD has mostly all HTML fields available.

2. Show/Hide fields: You can specify which fields to be shown in a form instead of showing all fields of the database table. You can also specify the different set of fields for insert, edit and view forms.

Show and Hide form fields

3. More fields customization: Apart from these 2 major used, PDO has lots of features to customize the form fields.  You can specify the HTML attributes for each field to perform javascript or CSS related tasks. You can add static fields like “I agree to terms and condition” that are not inserted in the database, Set field value of form directly, reset form, specify placeholder and tooltip, group similar fields, specify the fields display order, field conditional logic, add fields formula to change value of the field before insert/update operation, field required state, field validation, etc.

4. Related Data: When your main table contains the fields related to other tables then you can use the related data function to easily get data from other tables and also display as list in the forms. For example, if you want to display crud for “student” table containing class_id which is related to “class” table (columns class_id, class_name ) then you can easily display class_name instead of class_id using the related data. Also, it converts the field class_id to dropdown with display field text as “class_name” and value saved will be “class_id”. Example

https://pdocrud.com/demo/pages/related-data

Grid/Table Customization: The grid/table showing the records of a database table can be customized in many ways using PDO CRUD function. Let’s check out various feature related to grid/table customizations.

  1. Show/Hide Columns: If you want to show only a few columns, instead of all database table columns, you can specify either which columns to be shown or which column you want to hide.
  2. Column data type: You can define the data type of column to “URL” or “image” to display data as “URL” or “image” instead of text.
  3. Column data formatting: You can format the table data in many ways using PDO CRUD. You can change the data of column to upper case or lower case, add prefix or suffix, apply a formula, round a number, add read more, change the color of column based on specific conditions, generate HTML formatted text and many more.
  4. Dynamically Add column: You can create a new column by using two or more columns. You can add, subtract, merge, divide to generate new columns.
  5. More table Customization: You can change the table heading, subheading (default comes from the database table name), rename a column name, define width of column by setting column attributes, replace column value to something more easily understandable for user instead of database value, add column tooltips, set which actions buttons to be shown and add more action buttons. You can also create the switch (like on and off control) for column and action buttons. Result :
Grid/Table formatting using PDOCRUD

Design Customizations:   Lets now talk about how we can change the design of the table/grid and forms. PDO CRUD default design is a lightweight and clean interface but if you want to change it, you can easily do so.

  1.  Skins: Apart from default skin, PDO CRUD provides various skins dark, fair, green and advanced skins as other options to choose from. Skin is basically a CSS file, you can create a new skin file easily by copying existing skin file and changing the required CSS.
  2. Templates: PDO CRUD comes with 4 different types of templates, bootstrap (Default), bootstrap4, pure and simple. You can use any of these templates or if you want to create a new template, you can easily do by copying the template folder and rename it, with the changes as you want in your template.
  3. CSS & Other Customizations: You can specify CSS attributes on form fields as well as table columns and use the  CSS to change the design. PDO CRUD also comes with RTL option. Also, You can hide footer column name, change the color of rows based on some conditions and many more.

JOIN: PDO CRUD supports both INNER Join as well as LEFT JOIN.  You can define multiple inner joins for a table. Each student is associated with the unique class id and section id. Currently, it is showing id instead of class name and section name so let’s join these two tables to the main table student using the inner join.

Search: PDO CRUD has various features related to search the data. Default search allows you to search on the complete table as well as an individual column of the table.  You can also define the data type of search columns to search between dates. Also, you can enable the autosuggestion feature to make search more easy to operate. You can also add filters on various columns with different HTML types i.e. dropdown, radio button.

Plugins:  PDO CRUD comes with a bundle of useful jQuery/js plugins that helps to perform various tasks easily. We can easily convert a text area field to WYSIWYG editor by calling ckeditor/summernote on that field. Similarly, we can change the dropdown to auto search by using the popular jQuery plugins chosen/select2. You can use these plugins to easily create your dashboard. You can also add new plugin easily by following add plugin steps. List of plugins available currently includes:

  1. CKEditor
  2. Summernote
  3. Chosen
  4. Select2
  5. Calendar
  6. Vertical timeline
  7. Bootstrap tags
  8. Datatable
  9. Rate it
  10. Word counter
  11. Time picker
  12. Knob
  13. File input browser
  14. Password strength
  15. Input mask
  16. Color picker

MORE USEFUL FEATURES:  There are still many more features to cover but we will focus on a few more features that are useful to create application more useable.

  1. Inline Edit & Table Cell Edit: If you want to edit the records directly in the table/grid, you can achieve this easily using PDO CRUD. You can edit complete row inside the table as well as a single cell of a table similar to excel like editing. Demo:
    http://pdocrud.com/demo/pages/inline-edit
  2. BULK Editing: You can update multiple rows of data directly in grid/ so you can update multiple rows of data very fast. It is very useful when you need to edit/update multiple records. Also, you can import bulk data directly from CSV file in very less time. Demo:
    http://pdocrud.com/demo/pages/crud-table-bulk-update
  3. Image manipulations: You can easily manipulate the uploaded image. You will be able to resize images, make thumbnails, flip images, crop images, add an overlay (watermark), or add text to images. Demo:
    http://pdocrud.com/demo/pages/image-functions
  4. Database abstraction: PDO CRUD comes with PDOModel. PDOModel is a database abstraction and helper PHP class that helps to do insert, update, delete, select operation using PDO without writing any queries and with much lesser code. Demo:
    http://pdocrud.com/demo/pages/raw-data-operations
  5. Chart/Graphs: PDO CRUD has integrated with Google Chart library to produce the various types of chart/graphs directly from the database. Apart from the Google chart, you can use the easypie and sparkline to produce graph/charts. Demo :
    http://pdocrud.com/demo/pages/google-chart
  6. Callback functions: If you want to modify the data on various events like before showing or before insert/update/delete/view or after these operations, you can easily add callback function and modify the data before/after passing to user/system. Demo :
    http://pdocrud.com/demo/pages/callback-function-php
  7. One page template: You can use the one-page template to show the insert form and grid on the side by side display so instead of clicking on add, you can directly insert data for faster operation. Demo:
    http://pdocrud.com/demo/pages/one-page-template
  8. Nested table : PDOCrud allows the editing of related records of different table i.e. similar to nested table. Nested Table is a table inside a table. It is not stored in that way but similar concept is used. Demo :
    http://pdocrud.com/demo/pages/multi-table-relation

Conclusion

Okay, so we have reached end of topic but list of features offered by PDO Crud doesn’t seems to end.In next article, we are going to discuss about the login and user role management and how it can be easily done using PDO CRUD application. There are still lots to be covered. Best thing about this product is author is continuously adding new features and they provide outstanding support.  Considering the features offered by the pdocrud.com and regular updates,  I would like to say it is offered at quite a reasonable price. You will be able to do almost all crud related actions using pdo crud. Whether you are developing an application from scratch or adding more features in existing application, pdocrud.com is useful for both cases. 
Please feel free to share your comments, we would love to hear from you. 

Leave a Reply

Your email address will not be published. Required fields are marked *