09-19-2009, 03:55 AM
|
#1 (permalink)
|
|
The Addict
Join Date: Jun 2008
Posts: 335
Thanks: 2
|
Some input a new data model
Well more correctly a new way of accessing data, perhaps not new I've seen things like this on other scripts and just want to know what you all thought of it
php Code:
<?php$blog = new TCKObject; $blog-> setSubtype('blog_post') -> addRelationship($_POST[ 'BlogCategoryGUID'], 'blog_category') -> searchableTags($_POST[ 'tags'], ',') -> setOwner($_SESSION[ 'user'] ); $blog-> title = $_POST[ 'title']; $blog-> post = $_POST[ 'blog_body']; $blog-> dataToBeRemovedBecauseItsToLong = 'LOOOOOOOOOOOOOOOOOOOOOOOOOONNNNNNNNNNNGGGGGGGGGGGGG'; if( $blog-> save() ){ if( $blog-> dataToBeRemovedBecauseItsToLong-> length > 0 ) { $blog-> dataToBeRemoved-> delete(); } header('location: page.php?guid=' . $blog-> getGUID() ); }/** A user object with specific functions **/class TCKUser extends TCKObject { public function __construct($guid = null) { parent:: __construct($guid); //Define the type of object $this-> setType('user'); } public function addFriend ( $guid ) { $this-> addRelationship($guid, 'friend'); } public function retrieveFriends ($count = false) { return $arrayOfFriends; } public static function getPopularUsers () { //Parameters: metastring name, metastrings value, the type of object, //and the owner of the object since we don't know 0 the default will suffice //null ( default ) returns all and finally if you just want //a count - set the fourth to true $users = parent:: search('popular', true, 'user', 0, null, false); if( $users ) return $users; //I just returns X number of objects representing his friends }}//GUID Of loggedin user$user = new TCKUser (102); if( $user-> retrieveFriends(true) > 50 ){ $user-> popular = true; $user-> save(); }//Retrieve all popular users$popularUsers = TCKUsers:: getPopularUsers();
|
|
|
|