Category: PHP Tutorial

python tutorials and learn python

Created with Sketch.

PHP PDO Transaction

PHP PDO Transaction Summary: in this tutorial, you will learn how to perform a database transaction from PHP by using PDO API. Introduction to PHP PDO transaction To start a transaction in PDO, you use the PDO::beginTransaction() method: $pdo->beginTransaction(); Code language: PHP (php) The beginTransaction() method turns off the autocommit mode. It means that the…
Read more

Call a MySQL Stored Procedure Using PHP PDO

Call a MySQL Stored Procedure Using PHP PDO Summary: in this tutorial, you will learn how to call a MySQL stored procedure using the PHP PDO. Setting up a stored procedure in MySQL To execute a statement in the MySQL database, you can use any MySQL client tool e.g., mysql client tool or MySQL Workbench.…
Read more

PDO FETCH_CLASS

PDO FETCH_CLASS Summary: in this tutorial, you’ll learn how to use the PDO::FETCH_CLASS mode to fetch data into an object of a class. Introduction to the PDO::FETCH_CLASS mode Suppose that you have the following books table in the database: CREATE TABLE IF NOT EXISTS books ( book_id INT AUTO_INCREMENT, title VARCHAR(255) NOT NULL, isbn VARCHAR(13)…
Read more

PDO FETCH_GROUP

PDO FETCH_GROUP Summary: in this tutorial, you’ll learn how to use the PDO::FETCH_GROUP mode to group the selected rows by the first column. Introduction to the PDO::FETCH_GROUP mode The PDO::FETCH_GROUP allows you to group rows from the result set into a nested array, where the indexes will be the unique values from the column and…
Read more

PDO FETCH_KEY_PAIR

PDO FETCH_KEY_PAIR Summary: in this tutorial, you’ll learn how to use the PDO FETCH_KEY_PAIR mode to select data from a table. Introduction to the PDO FETCH_KEY_PAIR mode Both fetch() and fetchAll() methods accept a very useful fetch mode called PDO::FETCH_KEY_PAIR. The PDO::FETCH_KEY_PAIR mode allows you to retrieve a two-column result in an array where the…
Read more

fetchObject

fetchObject Summary: in this tutorial, you’ll learn how to use the fetchObject() method to fetch the next row from a result set and returns it as an object. Introduction to the fetchObject() method Suppose that you have a pulishers table: CREATE TABLE IF NOT EXISTS publishers ( publisher_id INT AUTO_INCREMENT, name VARCHAR(255) NOT NULL, PRIMARY…
Read more

fetchColumn

fetchColumn Summary: in this tutorial, you’ll learn how to use the fetchColumn() method to get a single column from the next row of a result set. Introduction to fetchColumn() method Sometimes, you want to get the value of a single column from the next row of a result set. In this case, you can use…
Read more

fetchAll

fetchAll Summary: in this tutorial, you’ll learn how to use the PHP fetchAll() method of the PDOStatement object to return an array containing all rows of a result set. Introduction to the PHP fetchAll() method The fetchAll() is a method of the PDOStatement class. The fetchAll() method allows you to fetch all rows from a…
Read more

fetch

fetch Summary: in this tutorial, you’ll learn how to use the PHP fetch() method of the PDOStatement object to fetch a row from the result set. Introduction to the PHP fetch() method The fetch() is a method of the PDOStatement class. The fetch() method allows you to fetch a row from a result set associated…
Read more

PHP PDO Delete

PHP PDO Delete Summary: in this tutorial, you will learn how to delete one or more rows in a table from PHP using PDO. To delete one or more rows from a table, you can use a prepared statement. Here are the steps: First, make a connection to the database by creating a new instance…
Read more