本文整理汇总了PHP中SourceFactory::createInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP SourceFactory::createInstance方法的具体用法?PHP SourceFactory::createInstance怎么用?PHP SourceFactory::createInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SourceFactory
的用法示例。
在下文中一共展示了SourceFactory::createInstance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: while
if ($limit != "0") {
$stmt->setLimit($limit);
}
$count = $stmt->execute();
if ($count == 0) {
print "";
exit;
}
$cursor = $stmt->getCursor();
$res .= "<center><table>";
$res .= "<tr><th>Title</th><th>Starting URL</th><th>Next crawl date</th><th class='priority'>Priority</th></tr><tbody>";
while ($cursor->hasNext()) {
$rs = $cursor->getNext();
$query = array('$and' => array(array("type" => "cnx"), array("id" => intval($rs["type"]))));
mg_get_value($mg, "plugins", "class_php", $query, $class);
$source = SourceFactory::createInstance($class, $config, $id_account_current, $mg, $aLanguages, $aCountries);
$source->load($rs);
$res .= "<tr>";
$res .= "<td class='name'>";
$res .= $rs["name"] . " (id=" . $rs["id"] . ")";
$res .= "</td>";
$res .= "<td class='url'>";
$res .= getStartingUrls($source->getUrl());
$res .= "</td>";
$res .= "<td>";
$timestamp = $rs["crawl_nexttime"]->sec;
$now = time();
if ($now > $timestamp) {
$res .= "As soon as possible<br />(originally scheduled at " . date('Y-m-d H:i:s', $rs["crawl_nexttime"]->sec) . ")";
} else {
$res .= date('Y-m-d H:i:s', $rs["crawl_nexttime"]->sec);
示例2: require_once_all
require_once_all('sources/*.inc.php');
$db = db_connect($config, "", "", "");
$stmt = new db_stmt_select("sources");
$stmt->addColumn("*");
$s = $stmt->getStatement();
$rs = $db->Execute($s);
if (!$rs) {
echo "Error while reading sources table !";
exit;
}
$count = 0;
while (!$rs->EOF) {
$id = $rs->fields["id"];
// load
db_get_value($db, "plugins", "class_php", "id=" . $rs->fields["type"], $class);
$source = SourceFactory::createInstance($class, $config, $id_account_current, $db, null, null);
$source->load($rs->GetRowAssoc());
// delete
$delstmt = new db_stmt_delete('sources');
$delstmt->setWhereClause("id = '" . $id . "'");
$s = $delstmt->getStatement();
if (!$db->Execute($s)) {
echo 'Error while deleting record ' . $id;
exit;
} else {
// insert
$s = $source->getSqlStmt('insert');
if (!$db->Execute($s)) {
echo 'Error while writing record ' . $id;
echo '</br>Stop upgrade (' . $count . ' sources upgraded)';
echo '</br>' . $db->ErrorMsg();