Database Reference
In-Depth Information
Social Graph Model
This section explores the social graph model and a few of the operations that typically accompany the use of that type
of model. In particular, this section looks at the following:
Sign-up and Login
Updating a user
Creating a relationship type through a user by following other users
Managing user content, such as displaying, adding, updating, and removing status updates
The sample graph database used for these examples is loaded with data, so you can immediately begin working
with representative data in each of the graph models. In the case of the social graph—and for other graph models,
as well—you will login with the user ajordan . Going forward, please login with ajordan to see each of the working
examples.
Note
Sign Up
The HTML required for the user sign-up form is shown in Listing 8-16 and can be found in the {PROJECTROOT}/app/
templates/home/index.mustache file.
Listing 8-16. HTML Snippet of the Sign-Up Form
<form class="navbar-form navbar-left" action="/signup/add" role="form"
id="createaccountform" method="post">
<div class="form-group">
<input type="text" placeholder="Username" name="username"
class="form-control">
</div>
<button type="submit" class="btn btn-success">Create Account</button> &nbsp;
</form>
While the sample application creates a user without a password, I am certainly not suggesting or advocating
this approach for a production application. excluding the password property was done in order to create a simple sign-up
and login that helps keep the focus on the more salient aspects of the Neo4jPHP library.
Note
Sign-Up Route
In the sign-up route, start by doing a look up on the username passed in the request and see if it already exists in the
database using the getByUsername method found in the User service layer, as provided in Listing 8-17. If no match is
found, then the username is passed on to the saveUser method.
If no errors were returned during the save attempt, the request is redirected and a message is passed to thank the
user for signing up. Otherwise, the error message back to the home view informs the user of the problem.
 
 
Search WWH ::




Custom Search