Jump to content

How To Do Proper Database Query?


tiiberius

Recommended Posts

Hello,

 

How do you make a proper database query call?

 

What I need is to query the database to grab the tblinvoiceitems line item description and pass this into the line mentioned below as value field (X).

 

$code.='<input type="hidden" name="item_name" value="X">

 

How do I call the database and retrieve the tblinvoiceitems, then insert it correctly into value="" field?

 

 

 

Thank you in advance.

Link to comment
Share on other sites

Hi!

 

This depends on where you're accessing the database from. If you're accessing it from inside a WHMCS module (addon, gateway, registrar, etc.), you can use the Laravel query builder. The following code should get all the items in tblinvoiceitems for a certain item:

 

use Illuminate\Database\Capsule\Manager as Capsule;

$item = Capsule::table('tblinvoiceitems')->where('id', 1)->first();

 

Have a look here for further documentation about the Laravel query builder.

 

If you're trying to access it from anywhere outside WHMCS, I'd recommend having a look at PDO.

Link to comment
Share on other sites

Thank you for your response ducohosting.

 

Yes, it is within WHMCS. More specifically PayPal gateway module (paypal.php)

 

I understand the code you provided will be used as a hook correct?

 

How do I actually make the result of the query appear in the paypal.php?

 

Like I wrote I need it to show in the value field (X) in the following code:

 

$code.='<input type="hidden" name="item_name" value="X">

 

 

Thank you in advance.

 

 

 

Hi!

 

This depends on where you're accessing the database from. If you're accessing it from inside a WHMCS module (addon, gateway, registrar, etc.), you can use the Laravel query builder. The following code should get all the items in tblinvoiceitems for a certain item:

 

 

 

Have a look here for further documentation about the Laravel query builder.

 

If you're trying to access it from anywhere outside WHMCS, I'd recommend having a look at PDO.

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