本文整理汇总了PHP中Factory::getDatabase方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getDatabase方法的具体用法?PHP Factory::getDatabase怎么用?PHP Factory::getDatabase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory::getDatabase方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct($id)
{
$this->db = Factory::getDatabase();
$res = $this->db->query("select * from user where id = {$id} limit 1");
$this->data = $res->fetch_assoc();
$this->id = $id;
}
示例2: resolveDestinationPath
public function resolveDestinationPath($dir, $sourceInfo)
{
$log = Factory::getLogger();
$res = $this->mPeeler->resolveDestinationPath($dir, $sourceInfo);
$c = $this->getConfig();
$db = Factory::getDatabase();
switch ($c['peeler']['unique_by']) {
case 'url':
if ($db->urlDownloaded($sourceInfo['url'])) {
$log->message('Skipping %s (already downloaded)', $sourceInfo['url']);
$res = null;
}
break;
case 'checksum':
break;
}
return $res;
}
示例3: download
private function download($dir)
{
$c = $this->getConfig();
$db = Factory::getDatabase();
$log = Factory::getLogger();
$data = $this->mPeeler->getData();
$scraper = Factory::createScraper();
foreach ($data as $sourceInfo) {
$url = $sourceInfo['url'];
$log->message("Found %s", basename($url));
$scraper->get($url);
$res = $scraper->getResponseCode();
if ($dest = $this->resolveDestinationPath($dir, $sourceInfo)) {
if ($res == 200) {
$log->message("Writing %s", $dest);
file_put_contents($dest, $scraper->getResponseData());
$db->registerUrlDownloaded($url, $c['peeler']['name'], $dest, 'naming_ok');
} else {
$log->error("Server status %s", $res, $url);
}
}
}
}
示例4: __construct
function __construct()
{
$db = Factory::getDatabase();
$result = $db->query("select id from user");
$this->ids = $result->fetch_all(MYSQLI_ASSOC);
}
示例5: authenticate
private function authenticate()
{
if (empty($_SESSION['login']) && isset($_SESSION['post'])) {
$db = Factory::getDatabase();
$_SESSION['login'] = $db->verifyUser($_SESSION['post']['u'], $_SESSION['post']['p']);
}
unset($_SESSION['post']);
return !empty($_SESSION['login']);
}
示例6: setUserName
function setUserName($id, $name)
{
$db = Factory::getDatabase('master');
$db->query("update user set name = {$name} where id ={$id} limit 1");
}