105 lines
2.5 KiB
PHP
105 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace BRSystems\Core\Sys\sysActionLog\inc;
|
|
|
|
use BRSystems\Core\Library\cDb\cDb;
|
|
use BRSystems\Core\Library\cDbLog\cDbLog;
|
|
|
|
/**
|
|
* sysActionLog Module
|
|
*
|
|
* @category sysActionLog Module
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @since Version 2.0
|
|
*/
|
|
class sysActionLogModule
|
|
{
|
|
public $db;
|
|
|
|
/**
|
|
* Class constructor
|
|
*/
|
|
public function __construct() {
|
|
|
|
$this->db = cDb::getInstance();
|
|
|
|
}
|
|
|
|
/**
|
|
* Function to get module records
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category sysActionLog Module
|
|
* @param string $where - sql query
|
|
* @param string $sort - sql query
|
|
* @param int $offset - db table offset
|
|
* @param int $limitPerPage - limit per page
|
|
* @return array of data
|
|
* @version 1.1
|
|
*/
|
|
public function getModuleRecords($where, $sort, $offset = 0, $limitPerPage = 20){
|
|
|
|
$sSql = "
|
|
SELECT SQL_CALC_FOUND_ROWS
|
|
*
|
|
FROM
|
|
" . cDbLog::C_BASE_ACTION_TABLE . " ll
|
|
WHERE
|
|
1 {$where}
|
|
ORDER BY
|
|
{$sort}
|
|
LIMIT
|
|
{$offset}, {$limitPerPage}
|
|
";
|
|
|
|
$this->db->query($sSql);
|
|
return $this->db->getArray();
|
|
|
|
}
|
|
|
|
/**
|
|
* Function to delete table records form db
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category sysActionLog Module
|
|
* @param array $ids - record ids to delete
|
|
* @return bool true / false
|
|
* @version 1.1
|
|
*/
|
|
public function deleteRecords($ids){
|
|
|
|
$ids = implode(',', $ids);
|
|
return $this->db->execute("DELETE FROM `" . cDbLog::C_BASE_ACTION_TABLE . "` WHERE `id` IN ({$ids})");
|
|
|
|
}
|
|
|
|
/**
|
|
* Function to get record data by id
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category cmsCatFilters Module
|
|
* @param int $id - record id
|
|
* @return array - record data
|
|
* @version 1.1
|
|
*/
|
|
public function getRecordDataById($id){
|
|
|
|
return $this->db->_querySelectRow(cDbLog::C_BASE_ACTION_TABLE, false, array('id' => $id));
|
|
|
|
}
|
|
|
|
/**
|
|
* Function to delete all table records form db
|
|
*
|
|
* @author Mareks Keišs <mareks.keiss@brsystems.lv>
|
|
* @category sysActionLog Module
|
|
* @return bool true / false
|
|
* @version 1.1
|
|
*/
|
|
public function deleteAllRecords(){
|
|
|
|
return $this->db->execute("DELETE FROM " . cDbLog::C_BASE_ACTION_TABLE);
|
|
|
|
}
|
|
}
|