Пример #1
0
/** 
查询库里一共有多少记录
*/
function psearch_total()
{
    global $rpc_client;
    if (empty($rpc_client)) {
        $rpc_client = new PHPRPC_Client();
        $rpc_client->setProxy(NULL);
        $rpc_client->useService(SCH_API);
    }
    return $rpc_client->count(SCH_DB);
}
Пример #2
0
print_r($res);
$book2 = array("text" => "jojo", "author" => "ma", "name" => "goto");
$startitem = intval(file_get_contents("./offset"));
$k = 0;
for ($i = 933; $i < 3300; $i++) {
    $start = $i * 200;
    file_put_contents("./start", $start);
    $SQL = "SELECT id,name,author,brief FROM book LIMIT {$start},200";
    $conn = mysql_connect("h07-vm16.corp.cnb.yahoo.com", "yahoo", "");
    mysql_select_db("book", $conn);
    mysql_query("set names utf8");
    $rs = mysql_query($SQL);
    $num = mysql_num_rows($rs);
    if ($num == 0) {
        print "aHa,it's the end";
        break;
    }
    $rows = array();
    while ($row = mysql_fetch_assoc($rs)) {
        print $k++ . ",";
        $rows[] = $row;
    }
    file_put_contents("./k", $k);
    $j = $rpc_client->batch_index($db, $rows, array("text", "author", "name"));
    print "\n:{$k}:" . $j["code"] . "\n,";
    mysql_free_result($rs);
}
mysql_close($conn);
//print_r($rpc_client->index_data($db,"book1",$book1,array("text","author")));
var_dump($rpc_client->count($db));