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
# | |
# These queries check attributes values at the none-global store view scopes. | |
# | |
-- catalog_product_entity_datetime | |
SELECT a.* | |
FROM (SELECT * FROM catalog_product_entity_datetime) AS a | |
-- This inner join finds all store view-specific rows that exactly match the global scope value. The b.store_id = 0 conditional is key as it targets the global row | |
INNER JOIN (SELECT * FROM catalog_product_entity_datetime) AS b ON a.attribute_id = b.attribute_id AND a.entity_id = b.entity_id AND a.value = b.value AND b.store_id = 0 | |
WHERE a.store_id <> 0 | |
GROUP BY a.attribute_id, a.entity_id, a.value, a.store_id; |
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 | |
ini_set('max_execution_time', 600); | |
ini_set('memory_limit', '1024M'); | |
// ------------------------------- | |
$source = __DIR__ . '/images'; | |
$dest = __DIR__ . '/images.zip'; | |
// ------------------------------- | |
printf("Start zip '%s' %s to '%s'\n%s", $source, is_dir($source) ? 'directory' : 'file', $dest, zipDirOrFile($source, $dest)); |
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 | |
/* | |
* Usage [PHP >= 7.1] | |
* | |
require_once __DIR__ . '/Curl.php'; | |
$curl = new Curl('https://example.com'); | |
$curl->get(); | |
$curl->post(['key1' => 'value1']); |
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 | |
ini_set('max_execution_time', 600); | |
ini_set('memory_limit', '1024M'); | |
// --- CONFIG --------------------------------- | |
const DB_NAME = 'your_database'; | |
const DB_USER = 'root'; | |
const DB_PASS = 'xxxxxx'; | |
const DUMP_DIR = 'dumps'; |
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 | |
/* | |
* Usage | |
* | |
require_once __DIR__ . '/MySql.php'; | |
$mysql = new MySql('database', 'db_username', 'db_password'); | |
$rows = $mysql->select('table', 'col1 > 3 AND col2 = 10', 'col1, col2 DESC, col3, col4 ASC', [10 => 5]); // LIMIT 10 OFFSET 5 | |
$rows = $mysql->select(['table' => true], 'col1 > 3 AND col2 = 10', 'col1, col2 DESC'); // DISTINCT |
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 | |
/* | |
* Usage [PHP >= 7.1] | |
* | |
require_once __DIR__ . '/Csv.php'; | |
$csv = new CsvFile(__DIR__ . '/read_csv_file.csv'); | |
$csvRows = $csv->getRows(); | |
... | |
$csv->saveRows($csvRows, __DIR__ . '/save_csv_file.csv'); | |
*/ |
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 | |
/* | |
* Usage [PHP >= 7.1] | |
* | |
require_once __DIR__ . '/Cache.php'; | |
$cache = new Cache(__DIR__ . '/cache.json'); | |
$cache->set('key1', ['key1' => 'value1']); | |
print_r($cache->get('key1')); |
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 | |
// Recursive scan directories and collect data (use `scandir` function) | |
function scan_dir($dir) | |
{ | |
$result = []; | |
$filenames = array_diff(scandir($dir), ['.', '..']); | |
foreach ($filenames as $file) { | |
if (is_dir("$dir/$file")) { | |
array_push($result, ...scan_dir("$dir/$file")); |
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 | |
const CSV_FILENAME = __DIR__ . '/somefile.csv'; | |
$csvFile = file(CSV_FILENAME); | |
$data = []; | |
foreach ($csvFile as $line) { | |
$data[] = str_getcsv($line); | |
} |