Results: 1024
==
(Equal) Returns true if $x is equal to $y
$x = 40; 
$y = "40";
var_dump($x == $y); // true
===
(Identical) Returns true if $x is equal to $y, and they are of the same type
$x = 40; 
$y = "40";
var_dump($x === $y); // false
!=
(Not equal) Returns true if $x is not equal to $y
$x = 40; 
$y = "40";
var_dump($x != $y); // false
<>
(Not equal) Returns true if $x is not equal to $y
$x = 40; 
$y = "40";
var_dump($x <> $y); // false
!==
(Not identical) Returns true if $x is not equal to $y, or they are not of the same type
$x = 40; 
$y = "40";
var_dump($x !== $y); // true
>
(Greater than) Returns true if $x is greater than $y
$x = 40; 
$y = 50;
var_dump($x > $y); // false
<
(Less than) Returns true if $x is less than $y
$x = 40; 
$y = 50;
var_dump($x < $y); // true
>=
(Greater than or equal to) Returns true if $x is greater than or equal to $y
$x = 40; 
$y = 50;
var_dump($x >= $y); // false
<=
(Less than or equal to) Returns true if $x is less than or equal to $y
$x = 40; 
$y = 50;
var_dump($x <= $y); // true
Assignment operators are used with:
integer
and
float
values to write / update a variable value. Simple Assignment
$y = 9;
$x = $y;
echo $x . "\n";
Addition
$x = 40; $y = 9;
$x += $y; // same as: $x = $x + $y
echo $x . "\n";
Subtraction
$x = 40; $y = 9;
$x -= $y; // $x = $x - $y
echo $x . "\n";
Multiplication
$x = 40; $y = 9;
$x *= $y; // $x = $x * $y
echo $x . "\n";
Division
$x = 40; $y = 9;
$x /= $y; // $x = $x / $y
echo $x . "\n";
Modulus
$x = 40; $y = 9;
$x %= $y; // $x = $x % $y
echo $x . "\n";
Comparing two double numbers
The following code executes the
else
statement because the
float
numbers are different
if (strval(0.000000000035436064) == strval(0.000000000035436064000001)) {
    echo 'if';
} else {
    echo 'else';
}
But if we add one
0
in front of the last digit of the second number, then
if
statement will be executed
if (strval(0.000000000035436064) == strval(0.0000000000354360640000001)) {
    echo 'if';
} else {
    echo 'else';
}
Note:
The above code is one of the best solutions to compare float numbers
Show table sizes
Shows all the tables with their sizes in MB with descending order
SELECT 
    table_name AS `Table`, 
    round(((data_length + index_length) / 1024 / 1024), 2) AS MB_size 
FROM information_schema.TABLES 
WHERE table_schema = "database_name"
order by MB_size desc
UNIQUE several columns combined
Columns
token_id
and
base_price_pair
combined will be in the table
ALTER TABLE sdtokens.sdt_prices_unique
ADD UNIQUE (token_id, base_price_pair);
CREATE TABLE LIKE
Creates
sdt_prices_unique
table with exactly the same structure as
sdt_prices
table has
CREATE TABLE sdt_prices_unique LIKE sdt_prices
Make existing column UNIQUE
Makes
columnname
column UNIQUE
ALTER TABLE dbname.tablename
ADD UNIQUE (columnname)
INSERT IGNORE INTO
Inserts all rows, ignores rows with
Duplicate key
error
INSERT IGNORE INTO dbname.prices_unique
SELECT * FROM dbname.prices
Lost connection to MySQL server during query
When trying to import database the following problem occurred:
ERROR 2013 (HY000) at line 430: Lost connection to MySQL server during query
Solution to the problem was to increase connection timeout variable by running to following query:
SET GLOBAL connect_timeout = 10;
Disable / enable foreign key checks
First we disable
FOREIGN_KEY_CHECKS
to be able to run queries, then we enable
FOREIGN_KEY_CHECKS
back
SET FOREIGN_KEY_CHECKS=0;
--- Runs some SQL query - for example deleting some rows from a table that has foreign keys
SET FOREIGN_KEY_CHECKS=1;
Results: 1024