The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once



UserSpice
A patching question.. - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Miscellaneous (https://userspice.com/forums/forumdisplay.php?fid=28)
+--- Forum: Modifications and Hackery (https://userspice.com/forums/forumdisplay.php?fid=29)
+--- Thread: A patching question.. (/showthread.php?tid=556)



A patching question.. - wickey312 - 05-02-2017

Hi, so I'm relatively new to user spice but firstly thank goodness for this - my life is truly easier.

I am currently editing user profiles, changing columns etc. etc. For example, my users dont need to specify a first/last name, so effectively want to delete the cols. How does this work in userspice from a general point of view (does it break anything?) and does it effect the next patches - am I going to run into problems by deleting/modifying the default columns?

Thanks in advance


A patching question.. - mudmin - 05-03-2017

Awesome. Glad you're liking it so far.

In general, there's not really a performance benefit to deleting those columns. I don't think you'll run into issues as far as patching is concerned, though.

Basically, you'll want to do a find through the code and look for anything that calls $user->data()->fname and lname. I've programmed a lot of that out through the echouser function (so you can just set that to Username) in the admin dashboard. The only place I can think you might run into issues is on some of the email things and the user_settings page.

Anything you change that is a "core" userspice file should be done in usersc/

You'll have to change the path to the includes, etc, but the gist of it is that if you've modded a file (let's say login.php) if yours is in usersc/login.php it will ignore the core one and use yours, so the patches will not break your mods.



A patching question.. - wickey312 - 05-09-2017

Thanks mudmin..

One more question.. I'm trying to create queries to my dB which obviously userspice uses.. I don't want to effectively open up two connections if userspice already has one open.. Is there a way of using user spice to query the dB..


A patching question.. - Brandin - 05-09-2017

Mudmin made this awesome video below that will guide you through interacting with the DB:
https://www.youtube.com/watch?v=rb0kD5tCENM


A patching question.. - wickey312 - 05-09-2017

Great that's exactly what I needed.. thanks both - now lets pray that userspice never retires..


A patching question.. - firestorm - 05-09-2017

speaking of the db, I'm comfortable creating a patch file to update or create table/rows/columns etc, until i want to add multiple values to multiple columns, for example:

lets say my table is:
<pre>
Code:
$ctr1 = $db->query("CREATE TABLE <code>poppies</code> (
  <code>id</code> int(11) NOT NULL,
  <code>name</code> varchar(50) NOT NULL,
  <code>alpha_2</code> varchar(2) NOT NULL,
  <code>alpha_3</code> varchar(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1");

$ctr2 = $db->query("ALTER TABLE <code>poppies</code> ADD PRIMARY KEY (<code>id</code>)");
$ctr3 = $db->query("ALTER TABLE <code>poppies</code> MODIFY <code>id</code> int(11) NOT NULL AUTO_INCREMENT");
</pre>

now i want to update the table with multiple values for each column, for instance in column "name" i have 20 poppy names i need inserting,

normally if it was one value i would just do this:

<pre>
Code:
$fields = array(
  'name'  => 'yellow poppy',
  'alpha_2'  => '',
  'alpha_3'  => '',
);
$ctr4 = $db->insert('poppies',$fields);
</pre>


can user spice handle this ? or do i just have to import .sql via phpmyadmin?


A patching question.. - mudmin - 05-09-2017

@wickey312, I've built too many of my own projects on userspice to let it go away! haha. Although from May-August 1 are my crazy busy times at work so I don't get to do as much support and patching as I would like to.

I run a 500 acre kids camp up in Alaska, so when the sun is out, so are Alaskans!


A patching question.. - mudmin - 05-09-2017

@firestorm

I almost always do that with some sort of foreach loop.

I guess it depends. If I am entering the data in myself for the first time...I just go into phpmyadmin and do it that way. If I'm auto-generating the content from some sort of other query, I almost always go through a foreach.



A patching question.. - faguss - 05-28-2017

@firestorm

https://pastebin.com/Jp2EbDTw (line 202)

I've rewritten insert function so that you can add more than one record to a table.

Example:

Code:
$fields = array (
Code:
"Number" => array(1,2),
Code:
"Letter" => array("A","B")
Code:
);
Code:
$db -> insert("test_table",$fields);