Best way to store data in root SQL database using livephp

AeonCube

Member
Jul 18, 2007
10
0
51
Hi,
Developing a plugin for cPanel that will need to store data for a user when they fill in a form on the plugin. I need this to be stored in a database table in the root SQL DB as the user can't go change things from outside of the plugin form page.

Does anyone have a recommended way of doing this? If so any doc links or example code would be great!
Thanks,
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,227
463
Hello :)

Could you elaborate a little more on the nature of the plugin? For instance, are you integrating any cPanel functions?

Thank you.
 

KostonConsulting

Well-Known Member
Verifed Vendor
Jun 17, 2010
255
1
68
San Francisco, CA
cPanel Access Level
Root Administrator
When you install the plugin (you need to build your own installer), you can create a database as root and then you can access it through PHP's mysqli functions (PHP: Mysqli - Manual).

However, if you just need to store data for an individual user, using MySQL is probably not the way to go. You should use cPanel's NVData (non-volatile data store) functions to store individual user data: NVData Module Documentation

The main advantage of NVData over MySQL is that the data will be stored in the user's $HOME directory which means if their account is transferred to a different cPanel server, the data will still be available.