Permalink
Browse files

example

  • Loading branch information...
1 parent ccb318a commit 1f48371d85546f0b5e5c721197a18866b6455d7d @freekrai committed Mar 21, 2012
Showing with 34 additions and 2 deletions.
  1. +34 −2 README
View
36 README
@@ -2,11 +2,43 @@ Lawnchair.php is a port of PHP port of Lawnchair.js
See http://westcoastlogic.com/lawnchair/ for the original javascript library.
-
I mostly made this for something to try, and have tested with over 20,000 records in a table and had it work fast.
You have a choice of adapters, it can store it as text files or in a mySQL database, and you can build on that.
I'll do more documentation as I go..
-This also works really nicely with underscore.php
+This also works really nicely with underscore.php
+
+ <?php
+ include("Lawnchair.php");
+ $ppl = new Lawnchair( array("name"=>"people","store"=>"file") );
+ if( $ppl->count() < 1 ){
+ $ppl->save( array("value"=>array("name"=>"Roger") ) );
+ $ppl->save( array("value"=>array("name"=>"Kaitlyn") ) );
+ $ppl->save( array("value"=>array("name"=>"Patsy") ) );
+ $ppl->save( array("value"=>array("name"=>"Bailey") ) );
+ for($i = 0; $i <= 15000;$i++){
+ $ppl->save( array("value"=>array("name"=>$i) ) );
+ }
+ }
+ echo "<h1>List all Keys</h1>";
+ if( $ppl->count() < 10 ){
+ echo "<pre>".print_r($ppl->keys(),true)."</pre>";
+ }else{
+ echo "<p>Too many keys to list at once.. {$ppl->count()} keys found..</p>";
+ }
+ echo "<h1>Find all people with 'a' in the name </h1>";
+ $list = $ppl->find(array("field"=>"name","q"=>"a","a"=>"eq"));
+ echo "<pre>".print_r($list,true)."</pre>";
+ echo "<h1>List All People</h1>";
+ echo "<pre>".print_r($ppl->all(),true)."</pre>";
+
+ echo "Last Record is: ".print_r($ppl->max(),true)."<br />";
+ echo "Last Key is: ".$ppl->lastid();
+
+ echo "<h1>Max with callback</h1>";
+ echo "----> ".$ppl->max( function($member) { return "My name is: ".$member['name']; } )."<br />";
+
+ echo "<h1>Delete all records</h1>";
+ $ppl->nuke();

0 comments on commit 1f48371

Please sign in to comment.