This service has been discontinued

If you are a company selling whmcs modules and you are interested in our code you can contact us with an offer at info at whmcstricks dot com
All other requests will be ignored.

WHMCS database management intro

February 24, 2017

Unfortunately WHMCS documentation does not give enough information about database management.

On WHMCS 7 (actually from previous versions already) they implemented they take advantage of Laravel framework’s database component.

You can find some info on the WHMCS documentation that is probably useful if you don't need example to understand what to do. I think in this case is mandatory to include a link to Laravel query builder, for reference on how to create your queries.

First of all, to use it it's necessary to initialize Capsule, including this row of code at the beginning of your php file

use Illuminate\Database\Capsule\Manager as Capsule;

Now we can make queries, for example if we want to get all records from a table we can use:

$users = Capsule::table('users')->get();

Or if you want to retrieve a single column from a row:

$name = Capsule::table('users')->where('name', 'John')->pluck('name');

Update values in your database

Capsule::table('users')->where('id', 1)->update(array('votes' => 1));

Or insert a new row in the database

Capsule::table('users')->insert( array('email' => '[email protected]', 'votes' => 0));

One comment on “WHMCS database management intro”