本文整理匯總了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);