mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-07 19:29:20 +02:00
- add .editorconfig file - format all files to comply with castopod's coding style - switch parsedown dependency with commonmark library to better follow commonmark spec for markdown - add prettier command to format all project files at once closes #16
40 lines
1.2 KiB
PHP
40 lines
1.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Class AddAnalyticsUnknownUseragentsStoredProcedure
|
|
* Creates analytics_unknown_useragents stored procedure in database
|
|
* @copyright 2020 Podlibre
|
|
* @license https://www.gnu.org/licenses/agpl-3.0.en.html AGPL3
|
|
* @link https://castopod.org/
|
|
*/
|
|
|
|
namespace App\Database\Migrations;
|
|
|
|
use CodeIgniter\Database\Migration;
|
|
|
|
class AddAnalyticsUnknownUseragentsStoredProcedure extends Migration
|
|
{
|
|
public function up()
|
|
{
|
|
// Creates Stored Procedure for data insertion
|
|
// Example: CALL analytics_unknown_useragents('Podcasts/1430.46 CFNetwork/1125.2 Darwin/19.4.0');
|
|
$procedureName = $this->db->prefixTable('analytics_unknown_useragents');
|
|
$createQuery = <<<EOD
|
|
CREATE PROCEDURE `$procedureName` (IN `p_useragent` VARCHAR(191) CHARSET utf8mb4) MODIFIES SQL DATA
|
|
DETERMINISTIC
|
|
SQL SECURITY INVOKER
|
|
COMMENT 'Add an unknown useragent to table $procedureName.'
|
|
INSERT INTO `$procedureName`(`useragent`)
|
|
VALUES (p_useragent)
|
|
ON DUPLICATE KEY UPDATE `hits`=`hits`+1
|
|
EOD;
|
|
$this->db->query($createQuery);
|
|
}
|
|
|
|
public function down()
|
|
{
|
|
$procedureName = $this->db->prefixTable('analytics_unknown_useragents');
|
|
$this->db->query("DROP PROCEDURE IF EXISTS `$procedureName`");
|
|
}
|
|
}
|