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
Database abstraction and php tinkering
#1
Hi,

thanks for such wonderful platform, it is really cool.

I have done a couple of modifications myself that I think would be great to add to the platform in next versions, like for instance:
1: Upon login, let user choose whether to go to his profile or the main page
2: Let Admin define what is main page, same index (before login) or a new page (after logged in)
3: Different page based on access group? or even per user?

This was not a hard since it was just PHP tinkering, but now I wanted to make this into a full flesh app, with a lot of sql and dynamic pages, but I am at a lost as for the DB abstraction used.

I am familiar with adodb for php, and you seem to use the same nomenclature on your queries ($db -> .....) but I do not see the adodb folder anywhere.
Can you explain which method are you using? I would like to continue on the same line instead of having to create an alternative connection method.

  Reply
#2
I'm glad you're enjoying it.

We're currently working on storing these sorts of options in the database itself which will make the modifications a TON easier. We definitely don't want you to have to modify our code just to decide where someone redirects.

The DB stuff is super easy. I'm working on new documentation, but the current stuff explains it.

Regardless of whether you are updating or inserting, you want to put all of your data into an array before you do your query.
Code:
$fields=array('fname'=>$fname, 'lname'=>'$lname'); //column_name=>entry

Then, if you are INSERTING a new record, all you need is the table you are trying to insert into

So, it would be
Code:
$db->insert('users',$fields); //users is the name of the table in this example

If you are UPDATING, you need to know what record you are updating, so you need to give it that id.

Code:
$db->update('table_name',5,$fields);

To DELETE, you only really need to know the table and some form of logic. So do you want to delete when the username is “bob” or delete when the “id” equals 4. Whatever you want to do, just choose the table name and the logic.

Code:
$db->delete(‘table_name’,array(‘id’,’=’,4));

Pretty much everything you do is just a longer version of that. Does that make sense?

Here is the documentation. I'm happy to help if you need it for any other queries. Once you get it, you'll realize it's so simple and so much faster than doing things procedurally.
http://userspice.org/documentation-db-class-2/
  Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)