Need help syncing data from Couchbase to MySql


I am trying to sync documents from Couchbase to MySql but I am not able to do so
The above operation is taking place with a cron job (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')

The output of 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"

NOTE: The above code was working fine in Couchbase Enterprise Edition 5.0.1 build 5003 but when I updated the Couchbase to Couchbase Enterprise Edition 6.0.0 build 1693 ‧ IPv4 it is not working.

Pls help

How do I fix this?


Are you using the latest version of the SDK when running against 6.0?


hi eben,

sorry for the late reply,
Yes I am using the latest SDK against 6.0.



First, I would add some error handling. If the view response is returning an error, it doesn’t look like you’re checking it in the code. Is it that the app hangs/blocks when trying execute the query() that returns $results? Then, I would check the logs on the 6.0 cluster. See if there are any errors in the log. More details on the error, if any, might be in the logs.

After that, the next best diagnosis step @rizwan.shivalli would be to turn up the loglevel (see the docs, basically set envvar LCB_LOGLEVEL=5 ) and examine the conversation when running the view query.

Best would be to compare the 5.x and 6.x cluster. To not have too much, maybe adjust the code to only read 10 items or so. That’ll make for easier comparison.