PHP Programming: PHP Crush Course! Learn PHP Programming ...
User Relationships CMS PHP
-
Upload
prodigyview -
Category
Technology
-
view
1.241 -
download
3
description
Transcript of User Relationships CMS PHP
![Page 2: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/2.jpg)
Overview
Objective
Learn to create relationships between users, similar to social networking sites.
Requirements
Install version of ProdigyView with a database connection
Understanding of how to create a user
Estimated Time
10 Minuteswww.prodigyview.com
![Page 3: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/3.jpg)
Follow Along With Code Example
1. Download a copy of the example code at www.prodigyview.com/source.
2.Install the system in an environment you feel comfortable testing in.
3.Proceed to examples/user/UsersRelationships.php
![Page 4: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/4.jpg)
Having A Relationship
Having a relationship is nothing easy. It takes time, commitment, lot of moneys and sometimes lots of chocolate to feel loved if you are being neglected.
Thankfully in ProdigyView all you need to have is more than one user and you can define a relationship between them. We will be covering in tutorial:
Creating a relationship
Checking if a relationship exist
Modifying a relationship
Deleting a relationship(breaking up)www.prodigyview.com
![Page 5: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/5.jpg)
Add Some UsersOur example starts by first creating some users. If you are following along in the code example, there are two more users created besides the two below.
![Page 6: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/6.jpg)
Creating A RelationshipNow that we have our users present in the database, we can start creating relationships. It takes two to make this thing go right, so we at least require two users, a relationship type, and relationship status.
1. Add the first user 2. Add the second user
3. Set the relationship type4. Add the relationship status. Meaning of numbers is set by you. Example '1 could be ‘accepted’ and 0 mean ‘pending’.
![Page 7: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/7.jpg)
Database ViewYour database should look something like after adding the users.
www.prodigyview.com
![Page 8: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/8.jpg)
Searching RelationshipsNext we can search through our relationship using getUserRelationshipList() method. The method uses PV Standard Search arguments when querying for matches.
1. Search for users based on the requesting users field
2. The ‘,’ symbolizes an OR used in SQL
3. Returns the relationships as an array of arrays
![Page 9: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/9.jpg)
Compare RelationshipsSince we are pulling out our users, lets do some comparisons using the checkUserRelationship(). This method checks if there is an relationship among users. Explanation on next slide.
www.prodigyview.com
![Page 10: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/10.jpg)
Comparison Explanation1. Iterate through the relationships
2. Get the users information based on their user_id in the relationship
3. Print out the found relationship type 4. Check is there is any relationship based on the two users ids
5. Results on next slide
![Page 11: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/11.jpg)
The Comparison ResultsIf they are suppose be a family, something is definitely off.
![Page 12: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/12.jpg)
Removing A RelationshipObviously the relationships were not quite working out so it’s time for everyone to go there separate ways. I guess that means it’s time to delete some relationships.
Delete the relationship by passing in the relationship id
www.prodigyview.com
![Page 13: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/13.jpg)
Review
1. Add a relationship PVUsers::addUserRelationship()
2. Check if a relationship exist by using PVUsers::checkUserRelationship().
3. Search for user relationships with PVUsers::getUserRelationshipList()
4. Delete a user relationship with PVUsers::deleteUserRelationship()
www.prodigyview.com
![Page 14: User Relationships CMS PHP](https://reader033.fdocuments.in/reader033/viewer/2022061206/54828795b4af9f820d8b47c0/html5/thumbnails/14.jpg)
API ReferenceFor a better understanding of the users, visit the api by clicking on the link below.
PVUsers
www.prodigyview.com
More Tutorials
For more tutorials, please visit:
http://www.prodigyview.com/tutorials