This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXPLAIN SELECT * FROM products WHERE is_deleted = 0 AND status = 'ordered'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXPLAIN SELECT * FROM products WHERE is_deleted = 0 AND status = 'ordered'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SET autocommit=0; | |
INSERT INTO products (name, status) VALUES | |
('Product 1', 'live'), | |
... | |
('Product 10', 'live'); | |
COMMIT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ALTER TABLE `products` DISABLE KEYS; | |
INSERT INTO products (name, status) VALUES | |
('Product 1', 'live'), | |
... | |
('Product 10', 'live'); | |
ALTER TABLE `products` ENABLE KEYS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$aCity = new \stdClass(); | |
$aCity->name = 'Hamburg'; | |
$object = new \stdClass(); | |
$object->name = 'Marcel'; | |
$object->cities = [$aCity]; | |
echo data_get($object, 'name'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!empty($data['more']['complex'][0])) { | |
echo 'This code will never be executed'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = [ | |
'more' => [ | |
'complex' => ['my value'] | |
] | |
]; | |
if (array_key_exists('more', $data) && array_key_exists('complex', $data['more']) && array_key_exists(0, $data['more']['complex'])) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$data = ['likes' => 'Laravel']; | |
$object = new stdClass(); | |
$object->name = 'Marcel'; | |
$object->city = 'Hamburg'; | |
if (property_exists($object, 'name')) { | |
echo $object->name; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE `products` ( | |
`id` INT(11) NOT NULL AUTO_INCREMENT, | |
`name` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci, | |
`status` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '', | |
`is_deleted` TINYINT(1) DEFAULT '0' | |
) ENGINE=InnoDB; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Performance check if the index is hit | |
SET @start_time = NOW(); | |
SELECT * FROM products WHERE is_deleted = 0 AND status = 'ordered'; | |
SET @end_time = NOW(); | |
SELECT TIMEDIFF(@end_time, @start_time) AS difference; |
NewerOlder