コード例 #1
0
 public function deleteMustahiq($id)
 {
     $client = new Client(HelperController::getHost(), HelperController::getPort());
     $client->getTransport()->setAuth(HelperController::getUserNeo4j(), HelperController::getPassNeo4j());
     $status = 'failed';
     if (count($id) > 0) {
         $node = $client->getNode($id);
         if (count($node) > 0) {
             if (count($node->getProperties()) > 0) {
                 $labels = $node->getLabels();
                 $label = $labels[0]->getName();
                 if ($label == HelperController::getLabelMustahiq()) {
                     $cypher = 'START n=node(' . $id . ') MATCH n-[r]-() DELETE r, n';
                     $query = new Query($client, $cypher);
                     $query->getResultSet();
                     $status = 'success';
                 } else {
                     $status = 'failed, the label is not mustahiq check your parameter';
                 }
             } else {
                 $status = 'failed, the label is not mustahiq check your parameter';
             }
         } else {
             $status = 'failed, return value is empty check your mustahiq id ';
         }
     } else {
         $status = 'failed, mustahiq id is empty please check your parameter';
     }
     return response()->json(array('status' => $status));
 }