7. Putting it all together

So a common scenario would be retrieving data, manipulating the results and sending back to the database. Let's see with Eden's search, collection and model objects how we can acheive this.

Firgure 16. The Coolest Thing Ever!
//load database
eden('mysql', MYSQL_HOST, MYSQL_NAME, MYSQL_USER, MYSQL_PASS)
	//search user table
	->search('user')
	//WHERE user_gender = $_get['gender']
	->filterByUserGender($_GET['gender'])
	//ORDER BY user_id
	->sortByUserId('ASC')
	//LIMIT 75, 25
	->setStart(75)->setRange(25)
	//get a collection object
	->getCollection()
	//sets all users to active
	->setUserActive(1)
	//Set a new column post_title
	->setPostTitle('A '.$_GET['gender'].'\'s Post')
	//Set a new column post_detail
	->setPostDetail('Content is King')
	//Copy the contents of user_id to a new column post_user
	->copy('user_id', 'post_user')
	//Set a new column post_created
	->setPostCreated(time())
	->formatTime('post_created', 'Y-m-d H:i:s')
	//save to user table
	->save('user')
	//save to post table
	->save('post');

If you look at our next section B. PostGreSQL or even C. SQLite. You'll realize that it's the same documentation as this one with the exception of small changes basic query section. We normalized all SQL database objects to use the exact same thing to reduce the learning curve.


© 2012 Openovate Labs. All rights reserved.