Author: Administrator · Published: August 27, 2007 · Category: Database Show
Bila kita ingin melakukan pengolahan atau menampilkan data yang kebetulan data tersebut tersimpan pada database MySQL , sedangkan kita terbiasa melakukan query atau membuat interface dengan Ms.Access, kita tidak perlu meng-import data dari MySQL ke Ms.Access, tapi cukup dengan melakukan koneksi antara Ms.Access dengan database MySQL dengan bantuan module ODBC pada O/S Windows. Berikut langkah demi langkahnya. Download Tulisan Lengkap : setiaji-msaccesstomysql1.zip Related Articles
Throughout this tutorial for beginners you'll learn to use Laravel 8 - the latest version of one of the most popular PHP frameworks - to create a REST API CRUD web application with a MySQL database and Bootstrap 4 styles from scratch and step by step starting with the installation of Composer (PHP package manager) to implementing and serving your application. This tutorial is updated from our Laravel 6/7 tutorial Creating our Laravel 8 CRUD REST APIBefore implementing our Laravel 8 REST API CRUD application, let's see the prerequisites that we'll need to have for this tutorial. PrerequisitesThis tutorial assumes you have PHP and MySQL installed on your system. Follow the instructions for your operating system to install both of them. You also need to be familiar with Linux/macOS bash where we'll be executing the commands in this tutorial. Familiarly with PHP is required since Laravel 8 is based on PHP. For development I will be using a Ubuntu 18.04+ machine so the commands in this tutorial are targeting this system but you should be able to follow this tutorial in any operating system you use. Please check out the previous tutorial for how to Install Laravel 8 and PHP 7.3. We have cover the following topics in our previous post:
After we have installed Laravel 8 and created a new project, let's create our Laravel 8 REST API example. Creating a MySQL DatabaseLet's start by creating a MySQL database that we'll use to persist dat ain our Laravel 8 REST API application. In your terminal, run the following command to run the When prompted, enter the password for your MySQL server when you've installed it. Next, run the following SQL statement to create a
Open the
You need to enter the database name, the username and password. At this point, you can run the
Creating your First Laravel 8 ModelLaravel uses the MVC architectural pattern to organize your application in three decoupled parts:
Wikipedia defines MVC as:
Now, let's create our first Laravel Model. In your terminal, run the following command:
This will make a In the terminal, we get an output similar to:
Open the
We added the
You can now create the Now, let's look at our
Creating the Laravel 8 Controller and RoutesAfter creating the model and migrated our database. Let's now create the controller and the routes for working with the
Open the
The You can read the role of the method on the comment above it. Now we need to provide implementations for these methods. But before that, let's add routing. Open the
You can also use the following syntax:
Using the These routes are mapped to various
These routes are
used to serve HTML templates and also as API endpoints for working with the
Implementing the CRUD OperationsLet's now implement the controller methods alongside the views. C: Implementing the Create Operation and Adding a FormThe Let's implement these two methods. Re-open the Next, locate the
Next,
locate the
The Before creating the In the
Open the
Now, let's create the Next, create the template
Open the
This is a screenshot of our create form! Fill out the form and click on the Add contact button to create a contact in the database. You should be redirected to /contacts route which doesn't have a view associated to it yet. R: Implementing the Read Operation and Getting DataNext, let's implement the read operation to get and display contacts data from our MySQL database. Go to the
Next, you need to create the the index template. Create a Open the
U: Implementing the Update OperationNext, we need to implement the update operation. Go to the
Next, you need to implement the
Now, you need to add the edit template. Inside the Open the
U: Implementing the Delete OperationFinally, we'll proceed to implement the delete operation. Go to the
You can notice that when we redirect to the Go to the
We also need to add a button to takes us to the create form. Add this code below the header:
This is a screenshot of the page after we created a contact: ConclusionWe've reached the end of this tutorial. We created a REST API CRUD application with Laravel 8, PHP 7 and MySQL. Next, you can learn how to add authentication to your Laravel 8 app.
|