Transactions

A transaction is an indivisible unit of work. That said, a transaction cannot be divided or separated. In databases, a transaction involves multiple queries that require successful execution. If successfully executed, the transaction is committed. If one of the queries fails to execute, a rollback should be used for the entire transaction or parts of…

PHP: MySQLi Fetch

The following are common methods used to fetch data from a database using MySQLi. mysqli_stmt_fetch() Fetch results from a prepared statement into the bound variables. mysqli_fetch_all() Fetches all result rows and returns the result set as an associative array, a numeric array, or both. Available only with mysqlnd. mysqli_fetch_array()Fetch a result row as an associative, a…

How to not get hacked!

TIP 1: Do not trust user input of any format! Validate EVERYTHING and Sanitise EVERYTHING! TIP 2: Do not run outdated software in production. TIP3: Do not run code that you do not understand in production (e.g. copy/paste from tutorials). TIP4: Follow the rules of least privilege in your application and production host. TIP5: Learn…

Database Indexing

An Execution Plan are the steps the database needs to perform to execute a query, and for that there needs to be an appropriate access to the data. Most databases use index only. An index is an ordered representation of the indexed data. An index and a query are related and always have to go…