58 lines
1.9 KiB
PHP
58 lines
1.9 KiB
PHP
<?php if (!defined('BASEPATH')) {
|
|
exit('No direct script access allowed');
|
|
}
|
|
|
|
class Myfloat_version_model extends CI_Model
|
|
{
|
|
public function __constructor()
|
|
{
|
|
parrent::__constructor();
|
|
}
|
|
|
|
public function getVersionQuery($params = [])
|
|
{
|
|
$whereQuery = ' WHERE 1 = 1 ';
|
|
|
|
if (!empty($params['platform_filter'])) {
|
|
$whereQuery .= " AND platform_id = " . pg_escape_string(trim($params['platform_filter'])) . " ";
|
|
}
|
|
|
|
if (!empty($params['text_filter'])) {
|
|
$whereQuery .= " AND (name ILIKE '%" . $params['text_filter'] . "%' OR notes ILIKE '%" . $params['text_filter'] . "%' OR url ILIKE '%" . $params['text_filter'] . "%') ";
|
|
}
|
|
|
|
if (!empty($params['rev_count_filter'])) {
|
|
$whereQuery .= " AND mv.rev_count = " . pg_escape_string(trim($params['rev_count_filter'])) . " ";
|
|
}
|
|
|
|
if (!empty($params['short_hash_filter'])) {
|
|
$whereQuery .= " AND mv.short_hash ILIKE '%" . pg_escape_string(trim($params['short_hash_filter'])) . "%' ";
|
|
}
|
|
|
|
if (!empty($params['released_filter'])) {
|
|
// released_filter format: 2020-02-03 - 2020-03-01
|
|
$fromToArray = explode(' - ', $params['released_filter']);
|
|
$fromDate = $fromToArray[0];
|
|
$toDate = $fromToArray[1];
|
|
|
|
$whereQuery .= " AND to_char(mv.released, 'YYYY-MM-DD') >= '" . pg_escape_string($fromDate) . "'
|
|
AND to_char(mv.released, 'YYYY-MM-DD') <= '" . pg_escape_string($toDate) . "'
|
|
";
|
|
}
|
|
|
|
$query = "
|
|
SELECT
|
|
*,
|
|
mv.id AS id
|
|
FROM
|
|
myfloat_version mv
|
|
JOIN members_device_platforms mdp ON mv.platform_id = mdp.id
|
|
" . $whereQuery . "
|
|
ORDER BY
|
|
mv.id ASC
|
|
";
|
|
|
|
return $query;
|
|
}
|
|
}
|