我正在尝试使用Drupal cronjob从Couchbase Server执行同步到MySql
我试图将文件从Couchbase同步到MySql,但我无法这样做上面的操作是用cronjob(Drupal)进行的
function drupal_cron()
{
$cluster = new CouchbaseCluster("couchbase://localhost");
$cluster->authenticateAs('Admin', 'password');
$bucket = $cluster->openBucket("default");
$query = CouchbaseViewQuery::from('drupal', 'id')->reduce(false)->order(CouchbaseViewQuery::ORDER_DESCENDING);
var_dump($query); // getting data till here
$results = $bucket->query($query); // not going past this
var_dump($results); // no data here
foreach($results->rows as $row) //not going in the foreach loop because no data in $results
{
$doc_id = $row->id;
$doc = $bucket->get($doc_id);
// $doc = json_decode($doc->value);
$doc = $doc->value;
if ($doc->drupal_status == 'pending')
{
sync_code_here
}
}
}
var_dump的输出($ query)
object(Couchbase\ViewQuery)#108 (3)
{
["designDocumentName"]=> string(8) "drupal"
["viewName"]=> string(2) "id"
["options"]=> array(2)
{
["reduce"]=> string(5) "false"
["descending"]=> string(4) "true"
}
}
请帮忙
我该如何解决?
我需要在Couchbase Server中创建一个名为“Drupal”的新设计文档和名为“id”的新视图,以匹配并验证这一点
$query = CouchbaseViewQuery::from('drupal', 'id')->reduce(false)->order(CouchbaseViewQuery::ORDER_DESCENDING);
之后,它就像一个魅力。