How To Build Web Application CRUD with Codeigniter 3.1.0

How To Build Web Application CRUD with Codeigniter 3.1.0

This tutorial is about How To Build Web Application CRUD with Codeigniter 3.1.0

Introduction

In the previous section, we’ve create sign up and sign in method. The result of that is access token which can be used to manage data in every single communication with RestAPI. Now, you will try to make CRUD (Create, Read, Update, and Delete) in Mesosfer cloud platform using codeigniter 3.1.0.

Prerequisites

  • Sign up for an account in mesosfer cloud platform then create application to get applicationId.
  • Create bucket and add several columns based on your needs.
  • Download code from previous section.

Before write the code, you have to login on Mesosfer cloud platform and create bucket on your apps like the picture below:

how-to-build-web-application-crud-with-codeigniter-3-1-0

Click button create bucket then fill the name, recommended in pascal case. Based on sample code that is attached, you should give name with “Animal”. Like picture below :

how-to-build-web-application-crud-with-codeigniter-3-1-0-2

After that click menu add column, add 2 columns : name with type “String” and foot with type “Number”. It’s gonna be like that picture below :

how-to-build-web-application-crud-with-codeigniter-3-1-0-3

Let’s Write The Code!

In the previous section, we’ve create controller Animal.php and view/pages/animal.php. Now, we just complete method for CRUD. The first method is view the data. We have to query data in bucket animal first then forward to the view.

Set your appId appKey, and bucketName based on your apps. Then fill $client on construtor class.

Add script in method index to get all data in bucket animal.

To show data that querying from controller, we have to add script in /application/views/page/animal/view.php

If we access from browser, It will be like picture below.

how-to-build-web-application-crud-with-codeigniter-3-1-04

Add this script for handling navigation to page create in application/controller/Animal.php.

In the picture above there is link navigate to create new record. But we haven’t declare page to handle that. So let’s create. Add file create.php on application/views/page then fill script below :

After that you have to create method for handling action from create page. So that in animal controller we should add script below :

Let fill first data for bucket animal.

how-to-build-web-application-crud-with-codeigniter-3-1-0-6

After submit form, data that input automatically will added on table. Then in mesosfer cloud paltform also changed.

how-to-build-web-application-crud-with-codeigniter-3-1-7

how-to-build-web-application-crud-with-codeigniter-3-1-8

For handling edit and update selected record, we have to add method in Animal.php, method edit will retrieve one record based on objectId.

And we should add file edit.php in application/views/pages/animal/ to handle update data.

Here we test to update the data.

After you submitted, the table will automatically updated.

how-to-build-web-application-crud-with-codeigniter-3-1-9

For handling action delete, we should add script on application/controller/Animal.php

Let’s try and share to your community. Download complete code here.

Conclusion

Simplify data management with mesosfer cloud platform. You only need push and pull action without maintain server data, reduce development time, scallable and multiplatform.

Mesosfer helps you connect your project to the cloud. Cut off the development process so you can straight into the delivery process instead stumble on the complicated infrastructure.

Hi There!

Leave a Reply