forked from flashii/eeprom
Removed explicit DbType usage.
This commit is contained in:
parent
0da6cd7fe5
commit
cd1de984d4
3 changed files with 22 additions and 25 deletions
|
@ -4,7 +4,6 @@ namespace EEPROM;
|
|||
use RuntimeException;
|
||||
use JsonSerializable;
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\DbType;
|
||||
|
||||
final class Application implements JsonSerializable {
|
||||
public function __construct(
|
||||
|
@ -56,7 +55,7 @@ final class Application implements JsonSerializable {
|
|||
'SELECT `app_id`, `app_name`, `app_size_limit`, `app_expiry`, `app_allow_size_multiplier`,'
|
||||
. ' UNIX_TIMESTAMP(`app_created`) AS `app_created` FROM `prm_applications` WHERE `app_id` = ?'
|
||||
);
|
||||
$get->addParameter(1, $appId, DbType::INTEGER);
|
||||
$get->addParameter(1, $appId);
|
||||
$get->execute();
|
||||
$result = $get->getResult();
|
||||
|
||||
|
|
|
@ -9,7 +9,6 @@ use JsonSerializable;
|
|||
use Index\XString;
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\IDbResult;
|
||||
use Index\Data\DbType;
|
||||
|
||||
final class Upload implements JsonSerializable {
|
||||
public function __construct(
|
||||
|
@ -100,7 +99,7 @@ final class Upload implements JsonSerializable {
|
|||
$this->accessed = time();
|
||||
|
||||
$bump = $conn->prepare('UPDATE `prm_uploads` SET `upload_accessed` = NOW() WHERE `upload_id` = ?');
|
||||
$bump->addParameter(1, $this->id, DbType::STRING);
|
||||
$bump->addParameter(1, $this->id);
|
||||
$bump->execute();
|
||||
}
|
||||
|
||||
|
@ -142,8 +141,8 @@ final class Upload implements JsonSerializable {
|
|||
$this->expires = time() + $this->bump;
|
||||
|
||||
$bump = $conn->prepare('UPDATE `prm_uploads` SET `upload_expires` = NOW() + INTERVAL ? SECOND WHERE `upload_id` = ?');
|
||||
$bump->addParameter(1, $this->bump, DbType::INTEGER);
|
||||
$bump->addParameter(2, $this->id, DbType::STRING);
|
||||
$bump->addParameter(1, $this->bump);
|
||||
$bump->addParameter(2, $this->id);
|
||||
$bump->execute();
|
||||
}
|
||||
|
||||
|
@ -151,7 +150,7 @@ final class Upload implements JsonSerializable {
|
|||
$this->deleted = 0;
|
||||
|
||||
$restore = $conn->prepare('UPDATE `prm_uploads` SET `upload_deleted` = NULL WHERE `upload_id` = ?');
|
||||
$restore->addParameter(1, $this->id, DbType::STRING);
|
||||
$restore->addParameter(1, $this->id);
|
||||
$restore->execute();
|
||||
}
|
||||
|
||||
|
@ -166,12 +165,12 @@ final class Upload implements JsonSerializable {
|
|||
|
||||
if($this->dmca < 1) {
|
||||
$delete = $conn->prepare('DELETE FROM `prm_uploads` WHERE `upload_id` = ?');
|
||||
$delete->addParameter(1, $this->id, DbType::STRING);
|
||||
$delete->addParameter(1, $this->id);
|
||||
$delete->execute();
|
||||
}
|
||||
} else {
|
||||
$delete = $conn->prepare('UPDATE `prm_uploads` SET `upload_deleted` = NOW() WHERE `upload_id` = ?');
|
||||
$delete->addParameter(1, $this->id, DbType::STRING);
|
||||
$delete->addParameter(1, $this->id);
|
||||
$delete->execute();
|
||||
}
|
||||
}
|
||||
|
@ -223,16 +222,16 @@ final class Upload implements JsonSerializable {
|
|||
. ' `upload_expires`, `upload_bump`'
|
||||
. ') VALUES (?, ?, ?, ?, ?, ?, UNHEX(?), INET6_ATON(?), FROM_UNIXTIME(?), ?)'
|
||||
);
|
||||
$create->addParameter(1, $id, DbType::STRING);
|
||||
$create->addParameter(2, $appId < 1 ? null : $appId, DbType::INTEGER);
|
||||
$create->addParameter(3, $userId < 1 ? null : $userId, DbType::INTEGER);
|
||||
$create->addParameter(4, $fileName, DbType::STRING);
|
||||
$create->addParameter(5, $fileType, DbType::STRING);
|
||||
$create->addParameter(6, $fileSize, DbType::INTEGER);
|
||||
$create->addParameter(7, $fileHash, DbType::STRING);
|
||||
$create->addParameter(8, $_SERVER['REMOTE_ADDR'], DbType::STRING);
|
||||
$create->addParameter(9, $fileExpiry > 0 ? (time() + $fileExpiry) : 0, DbType::INTEGER);
|
||||
$create->addParameter(10, $bumpExpiry ? $fileExpiry : 0, DbType::INTEGER);
|
||||
$create->addParameter(1, $id);
|
||||
$create->addParameter(2, $appId < 1 ? null : $appId);
|
||||
$create->addParameter(3, $userId < 1 ? null : $userId);
|
||||
$create->addParameter(4, $fileName);
|
||||
$create->addParameter(5, $fileType);
|
||||
$create->addParameter(6, $fileSize);
|
||||
$create->addParameter(7, $fileHash);
|
||||
$create->addParameter(8, $_SERVER['REMOTE_ADDR']);
|
||||
$create->addParameter(9, $fileExpiry > 0 ? (time() + $fileExpiry) : 0);
|
||||
$create->addParameter(10, $bumpExpiry ? $fileExpiry : 0);
|
||||
$create->execute();
|
||||
|
||||
return self::byId($conn, $id);
|
||||
|
@ -269,7 +268,7 @@ final class Upload implements JsonSerializable {
|
|||
. ' LOWER(HEX(`upload_hash`)) AS `upload_hash`'
|
||||
. ' FROM `prm_uploads` WHERE `upload_id` = ? AND `upload_deleted` IS NULL'
|
||||
);
|
||||
$get->addParameter(1, $id, DbType::STRING);
|
||||
$get->addParameter(1, $id);
|
||||
$get->execute();
|
||||
$result = $get->getResult();
|
||||
|
||||
|
@ -291,7 +290,7 @@ final class Upload implements JsonSerializable {
|
|||
. ' LOWER(HEX(`upload_hash`)) AS `upload_hash`'
|
||||
. ' FROM `prm_uploads` WHERE `upload_hash` = UNHEX(?)'
|
||||
);
|
||||
$get->addParameter(1, $hash, DbType::STRING);
|
||||
$get->addParameter(1, $hash);
|
||||
$get->execute();
|
||||
$result = $get->getResult();
|
||||
|
||||
|
@ -313,7 +312,7 @@ final class Upload implements JsonSerializable {
|
|||
. ' LOWER(HEX(`upload_hash`)) AS `upload_hash`'
|
||||
. ' FROM `prm_uploads` WHERE `upload_hash` = UNHEX(?) AND `user_id` = ?'
|
||||
);
|
||||
$get->addParameter(1, $hash, DbType::STRING);
|
||||
$get->addParameter(1, $hash);
|
||||
$get->addParameter(2, $userInfo instanceof User ? $userInfo->getId() : $userInfo);
|
||||
$get->execute();
|
||||
$result = $get->getResult();
|
||||
|
|
|
@ -4,7 +4,6 @@ namespace EEPROM;
|
|||
use RuntimeException;
|
||||
use JsonSerializable;
|
||||
use Index\Data\IDbConnection;
|
||||
use Index\Data\DbType;
|
||||
|
||||
class User implements JsonSerializable {
|
||||
private static $active;
|
||||
|
@ -62,14 +61,14 @@ class User implements JsonSerializable {
|
|||
|
||||
public static function byId(IDbConnection $conn, int $userId): self {
|
||||
$create = $conn->prepare('INSERT IGNORE INTO `prm_users` (`user_id`) VALUES (?)');
|
||||
$create->addParameter(1, $userId, DbType::INTEGER);
|
||||
$create->addParameter(1, $userId);
|
||||
$create->execute();
|
||||
|
||||
$get = $conn->prepare(
|
||||
'SELECT `user_id`, `user_size_multiplier`, UNIX_TIMESTAMP(`user_created`) AS `user_created`,'
|
||||
. ' UNIX_TIMESTAMP(`user_restricted`) AS `user_restricted` FROM `prm_users` WHERE `user_id` = ?'
|
||||
);
|
||||
$get->addParameter(1, $userId, DbType::INTEGER);
|
||||
$get->addParameter(1, $userId);
|
||||
$get->execute();
|
||||
$result = $get->getResult();
|
||||
|
||||
|
|
Loading…
Reference in a new issue