Database Reference
In-Depth Information
Figure 8-19. Specific Products Purchased by Friends
Listing 8-46. The friends_purchase_by_product Route and Method
// specific product purchases by friends
$app->get('/intent/friendsPurchaseByProduct', $isLoggedIn, function() use ($app){
$mappedProductUserPurchaseList = Purchase::friendsPurchaseByProduct(
$_SESSION['username'],
"Star Wars Mimobot Thumb Drives");
$app->view()->setData(array(
'mappedProductUserPurchaseList' => $mappedProductUserPurchaseList,
'title' =>"Specific Products Purchased by Friends"));
$app->render('graphs/intent/index.mustache');
})->name('friendsPurchaseByProduct');
// a specific product purchased by friends
public static function friendsPurchaseByProduct($username,$title){
$queryString = " MATCH (p:Product) " .
" WHERE lower(p.title) =lower({title}) " .
" WITH p " .
" MATCH (u:User {username: {u} } )-[:FOLLOWS]-(f)-[:MADE]->()-[:CONTAINS]->(p) " .
" RETURN p.productId as productId, " .
" p.title as title, " .
" collect(f.firstname + ' ' + f.lastname) as fullname, " .
" null as wordPhrase, count(f) as cfriends " .
" ORDER BY cfriends desc, p.title ";
$query = new Everyman\Neo4j\Cypher\Query(Neo4Client::client(), $queryString, array(
'u' => $username,
'title' => $title
));
$result = $query->getResultSet();
return $result;
}
 
Search WWH ::




Custom Search