Jump to content

FROM Capsule::select TO Capsule::table


Davor

Recommended Posts

Hello,

if I understand correctly this help doc:

https://developers.whmcs.com/advanced/db-interaction/

that the WHMCS is deprecating the Select.

Could someone help me with converting this "Capsule::select" to "Capsule::table"?

Here is the code:

$currency = Capsule::select(Capsule::raw('SELECT t3.rate FROM tblinvoices AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id LEFT JOIN tblcurrencies AS t3 ON t2.currency = t3.id WHERE t1.id = "' . $vars['invoiceid'] . '" AND t3.default = "0" LIMIT 1'))[0];

 

Link to comment
Share on other sites

15 hours ago, Davor said:

Hello,

if I understand correctly this help doc:

https://developers.whmcs.com/advanced/db-interaction/

that the WHMCS is deprecating the Select.

Could someone help me with converting this "Capsule::select" to "Capsule::table"?

Here is the code:


$currency = Capsule::select(Capsule::raw('SELECT t3.rate FROM tblinvoices AS t1 LEFT JOIN tblclients AS t2 ON t1.userid = t2.id LEFT JOIN tblcurrencies AS t3 ON t2.currency = t3.id WHERE t1.id = "' . $vars['invoiceid'] . '" AND t3.default = "0" LIMIT 1'))[0];

 

$currency = Capsule::table('tblinvoices')
                ->leftJoin('tblclients','tblinvoices.userid','=', 'tblclients.id')
                ->leftJoin('tblcurrencies','tblcurrencies.id ','=', 'tblclients.currency')
                ->where('tblinvoices.id', $vars['invoiceid'])
                ->where('tblcurrencies.default', 0)
                ->select('t3.rate')
                ->first();
                
$currency->rate;

 

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