2022-01-09 03:49:51 +08:00
|
|
|
<?php
|
|
|
|
|
/**
|
|
|
|
|
* Created by PhpStorm.
|
|
|
|
|
* User: whwyy
|
|
|
|
|
* Date: 2018/3/30 0030
|
|
|
|
|
* Time: 14:39
|
|
|
|
|
*/
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace Database;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Interface ModelInterface
|
|
|
|
|
* @package Database
|
|
|
|
|
*/
|
|
|
|
|
interface ModelInterface
|
|
|
|
|
{
|
|
|
|
|
|
2023-12-18 15:01:08 +08:00
|
|
|
/**
|
|
|
|
|
* @param array|string|int $param
|
|
|
|
|
* @param null $db
|
|
|
|
|
* @return ModelInterface|null
|
|
|
|
|
*/
|
|
|
|
|
public static function findOne(array|string|int $param, $db = NULL): ?static;
|
2023-04-11 17:05:03 +08:00
|
|
|
|
|
|
|
|
|
2023-08-14 18:56:45 +08:00
|
|
|
/**
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function optimize(): mixed;
|
|
|
|
|
|
|
|
|
|
|
2023-12-18 15:01:08 +08:00
|
|
|
/**
|
|
|
|
|
* @param int $param
|
|
|
|
|
* @param null $db
|
|
|
|
|
* @return ModelInterface|null
|
|
|
|
|
*/
|
|
|
|
|
public static function primary(int $param, $db = NULL): ?static;
|
2022-01-09 03:49:51 +08:00
|
|
|
|
|
|
|
|
|
2023-12-18 15:01:08 +08:00
|
|
|
/**
|
|
|
|
|
* @param array $data
|
|
|
|
|
* @return static
|
|
|
|
|
*/
|
|
|
|
|
public static function populate(array $data): static;
|
|
|
|
|
|
2022-01-09 03:49:51 +08:00
|
|
|
|
2023-12-18 15:01:08 +08:00
|
|
|
/**
|
|
|
|
|
* @return ActiveQuery
|
|
|
|
|
* return a sql queryBuilder
|
|
|
|
|
*/
|
|
|
|
|
public static function query(): ActiveQuery;
|
2022-01-09 03:49:51 +08:00
|
|
|
|
|
|
|
|
|
2023-12-18 15:01:08 +08:00
|
|
|
/**
|
|
|
|
|
* @return ?string
|
|
|
|
|
*/
|
|
|
|
|
public function getPrimary(): ?string;
|
2022-01-09 03:49:51 +08:00
|
|
|
|
2022-01-20 19:04:15 +08:00
|
|
|
|
2023-12-18 15:01:08 +08:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
public function getTable(): string;
|
2022-01-20 19:04:15 +08:00
|
|
|
|
2022-01-09 03:49:51 +08:00
|
|
|
|
2023-12-18 15:01:08 +08:00
|
|
|
/**
|
|
|
|
|
* @return Connection
|
|
|
|
|
*/
|
|
|
|
|
public function getConnection(): Connection;
|
2022-01-09 03:49:51 +08:00
|
|
|
|
|
|
|
|
|
2023-12-18 15:01:08 +08:00
|
|
|
/**
|
|
|
|
|
* @param string $field
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function getAttribute(string $field): mixed;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $field
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
|
|
|
|
public function getOldAttribute(string $field): mixed;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $field
|
2023-12-18 16:03:24 +08:00
|
|
|
* @param mixed $value
|
2023-12-18 15:01:08 +08:00
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2023-12-18 16:03:24 +08:00
|
|
|
public function setAttribute(string $field, mixed $value): mixed;
|
2023-12-18 15:01:08 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $field
|
2023-12-18 16:03:24 +08:00
|
|
|
* @param mixed $value
|
2023-12-18 15:01:08 +08:00
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2023-12-18 16:03:24 +08:00
|
|
|
public function setOldAttribute(string $field, mixed $value): mixed;
|
2023-12-18 15:01:08 +08:00
|
|
|
|
|
|
|
|
|
2023-12-18 15:46:06 +08:00
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getOldAttributes(): array;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getAttributes(): array;
|
|
|
|
|
|
|
|
|
|
|
2023-12-18 15:01:08 +08:00
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function getChanges(): array;
|
2022-01-09 03:49:51 +08:00
|
|
|
|
|
|
|
|
}
|