01-08-2016, 12:53 AM
I've started making a video series of how to install UserSpice and what you can do with it after it's installed (with inspiration from DaVar), and once I got in there, I quickly hit the limits of the older UserCake code base. It's very functional for UserSpice itself and all the user management, but you would never want to build your own classes on that stuff. It's definitely going to be replaced in the future, but for the time being, I'm trying to support existing UserCake users.
Sooo, I've released a beta version that still uses the original user management system but gives you a major upgrade in what you can do to build your project once UserSpice is installed. Check out the /classes folder to see all the classes and what's available. Also check out the functions in the /helpers folder. Here are some of my favorites...
Most importantly, you need to instantiate the DB class to use it. You can do that by typing
Personally, I love the preformatted var_dump function
To insert into the database, you make an array of your fields then run the insert query, like this...
To delete from the database it is tablename, selector, and value so something like...
Updating is similar. Tablename, id and the same fields array
Find All
Or you can just find the first
Frustrated with the classes? Just run a basic or bound query, like this...
All this stuff is sanitized etc for your protection.
I hope that helps in your development! Videos will be launching shortly to show this stuff in action.
Sooo, I've released a beta version that still uses the original user management system but gives you a major upgrade in what you can do to build your project once UserSpice is installed. Check out the /classes folder to see all the classes and what's available. Also check out the functions in the /helpers folder. Here are some of my favorites...
Most importantly, you need to instantiate the DB class to use it. You can do that by typing
Code:
$db = DB::getInstance();
Personally, I love the preformatted var_dump function
Code:
dump($variable);
To insert into the database, you make an array of your fields then run the insert query, like this...
Code:
$fields=array('user_id'=>'$user_id', 'profile_pic'=>'dan.jpg'); //column_name=>entry
Code:
$db->insert('table_name',$fields);
To delete from the database it is tablename, selector, and value so something like...
Code:
$db->delete('users',array('id','=',4));
Updating is similar. Tablename, id and the same fields array
Code:
$db->update('camps',5,$fields);
Find All
Code:
$userQ = $db->findAll('camps');
Code:
$camps = $campQ->results(); //will give you a multidimensional array
Or you can just find the first
Code:
$first_camp = $campQ->first();
Frustrated with the classes? Just run a basic or bound query, like this...
Code:
$director_id = 1;
Code:
$query = $db->query("SELECT * FROM camps WHERE director_id = ?", array($director_id));
Code:
$x = $query->results();
All this stuff is sanitized etc for your protection.
I hope that helps in your development! Videos will be launching shortly to show this stuff in action.