public function logActivity($size = null, $master = false, $thumbnailId = null) { if (!env('DEBUG')) { $con = Pdo::getInstance()->getConnection(); $size = $size / 1024; $id = request()->source->id; $filename = $this->getFilename(); $method = request()->getMethod(); $userAgent = request()->getUserAgent(); $referer = request()->getReferer(); $ip = request()->getIp(); $identifier = $this->getIdentifier(); $con = $con->prepare("CALL LogActivity(:source_id, :thumbnail_id, :path, :method, :agent, :referer, :ip, :identifier, :filesize, :master)"); $con->bindParam(':source_id', $id, \PDO::PARAM_STR); $con->bindParam(':thumbnail_id', $thumbnailId, \PDO::PARAM_INT); $con->bindParam(':path', $filename, \PDO::PARAM_STR); $con->bindParam(':method', $method, \PDO::PARAM_STR); $con->bindParam(':agent', $userAgent, \PDO::PARAM_STR); $con->bindParam(':referer', $referer, \PDO::PARAM_STR); $con->bindParam(':ip', $ip, \PDO::PARAM_STR); $con->bindParam(':identifier', $identifier, \PDO::PARAM_STR); $con->bindParam(':filesize', $size, \PDO::PARAM_INT); $con->bindParam(':master', $master, \PDO::PARAM_INT); // call the stored procedure $con->execute(); } }
public static function getUsers($organisationId) { $ids = array(); $tmpIds = Pdo::getInstance()->all('SELECT `user_id` FROM `user_organisation` WHERE `organisation_id` = ?', [$organisationId]); foreach ($tmpIds as $id) { $ids[] = $id->user_id; } return ModelUser::getByIds($ids); }
public static function getBandwidthByDate($organisationId, $startDate = null, $endDate = null) { $where = [PdoHelper::formatQuery('`source_id` IN ((SELECT `id` FROM `source` WHERE `organisation_id` = %s))', array($organisationId))]; if ($startDate !== null) { $where[] = PdoHelper::formatQuery('`created` >= FROM_UNIXTIME(%s)', array(strtotime($startDate))); } if ($endDate !== null) { $where[] = PdoHelper::formatQuery('created <= FROM_UNIXTIME(%s)', array(strtotime($endDate))); } return Pdo::getInstance()->value('SELECT SUM(`filesize`) FROM `activity` WHERE ' . join(' && ', $where)); }
public function drop() { Pdo::getInstance()->nonQuery('DROP TABLE `' . $this->name . '`;'); }
public static function hasPayed($organisationId, $date) { return (bool) Pdo::getInstance()->value('SELECT COUNT(`id`) FROM `payment` WHERE `organisation_id` = ? && (`period_start` >= FROM_UNIXTIME(?) || `period_end` <= FROM_UNIXTIME(?))', [$organisationId, strtotime($date), strtotime($date)]); }
public function getLastActivity() { return Pdo::getInstance()->value('SELECT `last_activity` FROM `source` WHERE `organisation_id` = ? ORDER BY `last_activity` DESC LIMIT 1', [$this->id]); }
public function change() { $index = ''; if ($this->getIndex() !== null) { $index = sprintf(', ADD %s (`%s`)', $this->getIndex(), $this->getName()); } $query = 'ALTER TABLE `' . $this->table . '` MODIFY COLUMN ' . $this->getQuery() . $index . ';'; Pdo::getInstance()->nonQuery($query); }
public static function clear() { Pdo::getInstance()->nonQuery('DELETE FROM `settings`'); }
public static function escape($value) { return trim(Pdo::getInstance()->getConnection()->quote($value), '\''); }