Lädt...


🔧 Easy CRUD and database connection with openCrud


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Summary

open-crud is an open-source package created in native PHP that simplifies connecting to MySQL databases and makes it easier to manage databases using object-oriented programming.

Some challenges 💎

📌 How to connect my app on MySQL database?
⚙️ How to make CRUD easier to use?

In this documentation, we want to explain you how OpenCRUD package can be connected to your application and use different operations to manage your datas from a mySql database.

Installation 🛠️

  1. Requirements
  • Be sure to have a PHP version that is up to date.
  • You might know object-oriented programming, or you might not.
  1. Connection
    Download and insert the package in your project.

  2. Create the mySQL database.

  • Initialise your database informations in the /database/db-infos.php file.

  • Link the init.php in the file that you need to instantiate OpenCRUD.

Note : By default, initialise the $dbname variable with your database's name.

MySql rules : Your table's attributes will have the null value by default. Except the primary key.

  1. Instanciation

To interact with OpenCrud's database, create an object instance. This object acts as a representation of one or more database tables, and it provides methods for performing CRUD operations (Create, Read, Update, and Delete) on the table data.

# I instantiate the users table
$users = new Crud($users, $attributes, $type);

The required params :

array $tables is specify the table(s) that we need to use.
array $attributes will have access to the table's attributes and to the foreigner key(s) also if necessary.
bool $type return a row of values in case of false value. Else, it returns a row of objects values.

Getting started 🚀

Create

The create operation allow you to save datas by calling the create method of the instantiated object.

# The save a data
$users->create($formData);

The create method requires an array of data to be saved, excluding the primary key. However, it accepts foreign keys for establishing relationships with other data entities.

Read

The read operation retrieves datas from the database and display them to the user interface. The read operation can handle different parameters as needed. To improve code organization and readability, it's recommended to assign the read method to a variable.

# I get datas
$getDatas = $users->read($fields, $condition, $values, $limit);

The required params :

array|null $fields select attribute(s) of the table instantiated.
Sort datas with the string|null $condition if necessary.

# Query statement
$condition="name='john' and postname='doe'"

=> The $values param should have null value

# Prepared statement
$condition="name=? and postname=?"

=> The $values param should be an array
ex. $values = ['john', 'doe'];
Note : The fields param can be initialize by '*' to return all datas.

array $values must get values of the attributes in the condition.

Note : The initialisation of this variable require a prepared statement.
array|int $limit select datas. Else, you can use an array.

Select only 5 datas

$limit = 5

# Select by the 5th to 10th data
$limit = [5, 10];

### Update

The update operation refers to actions that modify existing data within a database or storage system. It allows you to change specific values or attributes of a record without deleting and recreating it entirely.

# Update users data
$users->update($id, $formData);

The required params :

int $id select the specific data to update.
array $formDatas contain new informations of a data.

Note : The array $formData should have the values of attributes of the table.

Delete

The Delete operation refers to the functionality that allows you to remove data from a database or storage system. It's the process of permanently erasing a specific record or set of records based on certain criteria.

# Remove a user data
$users->delete($id);

The required param :

With the int $id param, you can select the data.

...

🔧 Easy CRUD and database connection with openCrud


📈 76.43 Punkte
🔧 Programmierung

🔧 AddGraph supports straight line connection, curve connection, and polyline connection


📈 30.29 Punkte
🔧 Programmierung

🕵️ rConfig up to 3.9.4 lib/crud/search.crud.php Command privilege escalation


📈 27.41 Punkte
🕵️ Sicherheitslücken

🔧 FastAPI Beyond CRUD Part 3 - Buiding a CRUD REST API


📈 27.41 Punkte
🔧 Programmierung

🔧 FastAPI Beyond CRUD Part 6 - CRUD With Async SQLModel (An Introduction to Dependency Injection)


📈 27.41 Punkte
🔧 Programmierung

🔧 Introducing saksh-crud: Simplify Your Node.js CRUD Operations


📈 27.41 Punkte
🔧 Programmierung

🔧 YugabyteDB Connection Manager: Introduction to the Database Resident Connection Pool


📈 25.68 Punkte
🔧 Programmierung

🔧 FastAPI Beyond CRUD Part 5 - Databases With SQLModel (Connection, Lifespan Events, And Models)


📈 24.62 Punkte
🔧 Programmierung

🕵️ Ether Easy Converter/Easy Creator/Easy Burner 1.4.24 Pufferüberlauf


📈 21.54 Punkte
🕵️ Sicherheitslücken

🕵️ Ether Easy Converter/Easy Creator/Easy Burner 1.4.24 memory corruption


📈 21.54 Punkte
🕵️ Sicherheitslücken

🔧 Build CRUD RESTful API Using Spring Boot 3, Spring Data JPA, Hibernate, and MySQL Database


📈 21.24 Punkte
🔧 Programmierung

🔧 FastAPI Beyond CRUD Part 15 - More Database And Schema Relationships


📈 21.24 Punkte
🔧 Programmierung

📰 The Illustrated TLS Connection - Every byte of a TLS connection explained and reproduced


📈 20.61 Punkte
📰 IT Security Nachrichten

🔧 Differences between Persistent Connection and Non-Persistent Connection


📈 20.61 Punkte
🔧 Programmierung

🕵️ rConfig 3.9.5 Back-End Database devices.crud.php custom_Location sql injection


📈 20.01 Punkte
🕵️ Sicherheitslücken

🔧 FastAPI Beyond CRUD Part 7 - Create a User Authentication Model (Database Migrations With Alembic)


📈 20.01 Punkte
🔧 Programmierung

🕵️ H2O bis 1.7.2/2.0.0-beta4 HTTP2 Connection Handler lib/http2/connection.c Pufferüberlauf


📈 19.38 Punkte
🕵️ Sicherheitslücken

🕵️ H2O bis 1.7.2/2.0.0-beta4 HTTP2 Connection Handler lib/http2/connection.c Pufferüberlauf


📈 19.38 Punkte
🕵️ Sicherheitslücken

🕵️ Blue Coat SSL Visibility bis 3.11.3.0 SSL Connection TCP Connection Denial of Service


📈 19.38 Punkte
🕵️ Sicherheitslücken

📰 Inbound Connection Vs Outbound Connection.


📈 19.38 Punkte
📰 IT Security Nachrichten

🕵️ Blue Coat SSL Visibility up to 3.11.3.0 SSL Connection TCP Connection denial of service


📈 19.38 Punkte
🕵️ Sicherheitslücken

🕵️ Cisco Unity Connection Bulk Administration Tool Connection Request denial of service


📈 19.38 Punkte
🕵️ Sicherheitslücken

🐧 Connection problem, every connection has 0 segnal strenght. please tell me there Is a fix


📈 19.38 Punkte
🐧 Linux Tipps

🎥 The Power of connection: How practicing connection can transform teamwork within your organization


📈 19.38 Punkte
🎥 Video | Youtube

🔧 MySQL Connection Security With Connection Control Plugins


📈 19.38 Punkte
🔧 Programmierung

🔧 Understanding Database Connection Management in Spring Boot with Hibernate and Spring Data JPA


📈 17.22 Punkte
🔧 Programmierung

🔧 Universal Links Made Easy: Web-Mobile Connection for All Developers #1 — iOS World


📈 16.87 Punkte
🔧 Programmierung

🪟 Dead By Daylight Connection Issues: 5 Easy Solutions


📈 16.87 Punkte
🪟 Windows Tipps

🔧 Building a Fast and Flexible CRUD API with Node.js and MongoDB Native Drivers


📈 16.16 Punkte
🔧 Programmierung

🕵️ Cisco Intercloud Fabric for Business 7.3(0)ZN(0.99) Database Connection erweiterte Rechte


📈 15.99 Punkte
🕵️ Sicherheitslücken

🕵️ Cisco Intercloud Fabric for Business 7.3(0)ZN(0.99) Database Connection erweiterte Rechte


📈 15.99 Punkte
🕵️ Sicherheitslücken

🕵️ phpMyAdmin 4.0/4.4/4.6 MySQL Database Connection erweiterte Rechte


📈 15.99 Punkte
🕵️ Sicherheitslücken

🕵️ EZ-Shop cut Connection Database vulnerability


📈 15.99 Punkte
🕵️ Sicherheitslücken

matomo