请允许我说,我有一个称为<代码>Medium的班子,可以代表不同类型的媒体。 例如:
- uploaded video
- embedded video
- uploaded image
- embedded image
我与与会者一样代表这些类型:
class MediumAbstract
{
const UPLOAD = 0x0001;
const EMBED = 0x0010;
const VIDEO = 0x0100;
const IMAGE = 0x1000;
const VIDEO_UPLOAD = 0x0101; // for convenience
const VIDEO_EMBED = 0x0110; // for convenience
const IMAGE_UPLOAD = 0x1001; // for convenience
const IMAGE_EMBED = 0x1010; // for convenience
const ALL = 0x1111; // for convenience
}
因此,我很容易在一个(地下)存放处对他们进行联合搜查,例如:
{
public function findAllByType( $type )
{
...
}
}
$media = $repo->findAllByType( MediumAbstract::VIDEO | MediumAbstract::IMAGE_UPLOAD );
// or
$media = $repo->findAllByType( MediumAbstract::ALL );
// etc..
你们如何看待在数据库等具体存放处使用这些固定价值? 它吗? 或者,我应该用数据库中有意义的数据来替代它们。
Table medium:
| id | type | location | etc..
-------------------------------------------------
| 1 | use constants here? | /some/path | etc..
(当然,我只使用有意义的不变: VIDEO_UPLOAD, VIDEO_EMBED, IMAGE_UPLOAD and IMAGE_EMBED