The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
UserSpice 3.1.0beta Released - Great stuff
#1
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
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.
  Reply
#2
If you happened to download UserSpice 3.1.0beta within the first few hours, the helpers file might not have properly included. When I included it, there was a sanitize function that conflicted with the old UserCake Sanitize function.

I renamed all references to the old function to sanitize2 since they will eventually be going away and properly included the helpers file that contains the useful dump function. I know that function is only 3 lines of code or something, but I use it constantly.

If the filename you downloaded is UserSpice3.1.0betaB or later, this has been fixed.
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)