× 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
Is there a reason for the order of arguments in findById()
I think every single function in DB.php has the first argument as $table ... except findById().

Is there a reason for this? Maybe if I had the reason for it in my mind I would make the mistake less often...
The function pretty much always needs to know what table to look in. We could make a searchDB function or something that would search the whole db.

What do you see as the downside with this?
Sorry, I wasn't clear. My concern wasn't that every function has table as the first argument - my concern is that findById doesn't. It's the inconsistency in the order of arguments that I'm asking about.
@mudmin will definitely need to answer that one...I got nothing except agreement with you.

What do you think a solution would be? What are your thoughts on swapping the arguments in US5 for example.

I was going to make up a more educated sounding answer, but that method was actually the first method I ever wrote on my own. I used something similar in a procedural php class that I took on Udemy when I first started coding. I thought it would be a nice feature to have.

The method is not actually used anywhere in the UserSpice code. I didn't notice that until after I pushed 4.0 and got a few thousand downloads. I thought about changing it, but then if anyone implemented it, it would break their code. I'd kind of like to flip it for 5.0 and just document the change.
@mudmin good answer Big Grin
Try replacing your us_helpers.php file with this one


And see if it acts like you're thinking it should. In that case, if you don't have a page in the db, it will add it instead of tossing an error. If it can't add it, THEN it will toss the error. There could be bugs, but it's worth a shot. If it doesn't work, you can just replace it with the original.
I think you got the wrong thread on this one @mudmin...
Ooops. Thanks.

Forum Jump:

Users browsing this thread: 1 Guest(s)