PDO basic operation of PHP
The difference between PDO and Mysqli
For PHP 5 and above, the following methods are recommended to connect to MySQL:
MySQLi extension ("i" means improved)
PDO (PHP Data Objects)
PDO is used in 12 different databases, MySQL is only for MySQL database.
Both support preprocessing statements to ...
Posted by Zssz on Fri, 21 Feb 2020 08:49:47 +0100
Deepening PHP Object-Oriented, Patterns and Practice - Advanced Features (1)
Static methods and attributes
We can access methods and attributes not only through objects, but also through classes. Such methods and attributes are "static" and must be declared with the static keyword.
class StaticExample
{
static public $aNum=0;
static public function sayHello()
{
self::$aNum++;
p ...
Posted by crawfd on Thu, 18 Jul 2019 01:25:38 +0200
PHP Best Practices Database
PDO Extension
PHP natively provides PDO extensions, meaning PHP data objects.
Database Links and DSN
DSN refers to the name of the data source, providing detailed information about database links. Generally, it contains the following information:
Host name or IP address
Port number
Database name
character set
The DSN constructed by the above ...
Posted by tsinka on Wed, 12 Jun 2019 22:40:39 +0200
Filtration, validation, escape and password of PHP best practices
Filtration, validation and escape
1) Don't trust any data from data sources that are not directly controlled by you. Including but not limited to:
$_GET
$_POST
$_REQUEST
$_COOKIE
$argv
php://stdin
php://input
file_get_contents()
Remote database
Remote API
Data from the client
2) Solution: filter input. To delete unsafe characters, data must b ...
Posted by werkkrew on Tue, 11 Jun 2019 21:58:17 +0200