當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SourceFactory::createInstance方法代碼示例

本文整理匯總了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);
開發者ID:ejemba,項目名稱:crawl-anywhere,代碼行數:31,代碼來源:content.status.ajax.inc.php

示例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();
開發者ID:swapnilphalak,項目名稱:crawl-anywhere,代碼行數:31,代碼來源:upgrade_db_v300.php


注:本文中的SourceFactory::createInstance方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。