The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Best way to store data in root SQL database using livephp

Discussion in 'cPanel Developers' started by AeonCube, Jun 11, 2014.

  1. AeonCube

    AeonCube Member

    Joined:
    Jul 18, 2007
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    1
    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,
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,854
    Likes Received:
    675
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  3. KostonConsulting

    KostonConsulting Well-Known Member

    Joined:
    Jun 17, 2010
    Messages:
    255
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    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.
     
Loading...

Share This Page