Jump to content

Trouble using new whmcs sql helper functions


hpk

Recommended Posts

Hello,

 

I am trying to use new whmcs sql helper functions listed here:

 

http://docs.whmcs.com/SQL_Helper_Functions

 

However including the following directly in page:

 

<?php

require_once('/home/acct/public_html/whmcs/vendor/autoload.php');


use Illuminate\Database\Capsule\Manager as Capsule;

// Print all client first names using a simple select.

/** @var stdClass $client */
foreach (Capsule::table('tblclients')->get() as $client) {
   echo $client->firstname . PHP_EOL;
}

// Rename all clients named "John Deo" to "John Doe" using an update statement. 
try {
   $updatedUserCount = Capsule::table('tblclients')
       ->where('firstname', 'John')
       ->where('lastname', 'Deo')
       ->update(
           [
               'lastname' => 'Doe',
           ]
       );

   echo "Fixed {$updatedUserCount} misspelled last names.";
} catch (\Exception $e) {
   echo "I couldn't update client names. {$e->getMessage()}";
}

 

results in error:

 

Call to a member function connection() on a non-object in /home/acct/public_html/whmcs/vendor/illuminate/database/Illuminate/Database/Capsule/Manager.php on line 110

 

Any help?

 

Thanks a lot!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated