本文整理汇总了PHP中DatabaseFactory::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseFactory::factory方法的具体用法?PHP DatabaseFactory::factory怎么用?PHP DatabaseFactory::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DatabaseFactory
的用法示例。
在下文中一共展示了DatabaseFactory::factory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFactory
public static function getFactory()
{
if (!self::$factory) {
self::$factory = new DatabaseFactory();
}
return self::$factory;
}
示例2: __construct
public function __construct()
{
$this->connection = mysql_connect('localhost', 'root', '');
mysql_select_db('test', $this->connection);
mysql_set_charset('utf8');
}
public function userExists($email)
{
$emailEscaped = mysql_real_escape_string($email);
$query = "SELECT * FROM user WHERE email='" . $emailEscaped . "'";
if ($result = mysql_query($query, $this->connection)) {
return mysql_num_rows($result) > 0 ? true : false;
} else {
return 12345;
}
}
}
class DatabaseFactory
{
public static function factory($type)
{
switch ($type) {
case 'MYSQL':
return new MYSQL();
break;
}
}
}
$db = DatabaseFactory::factory('MYSQL');
$result = $db->userExists('128@qq.com');
var_dump($result);