Jump to content

whmcs fetch data from mysql


xedro99

Recommended Posts

Hey there everyone,

 

I am currently having trouble in fetching data from the mysql table from the WHMC's database, the table is of a whmcs addon and till not I have used this hook to fetch the data

 

<?php
# Get Product Group PIDs Hook
# Written by brian!
use Illuminate\Database\Capsule\Manager as Capsule;
function get_productIDs_for_specified_groups_hook($vars) {
	if ($vars['templatefile'] == 'products') {
		$gid = $_SESSION['products']['pid'];
		$hour = Capsule::table('mod_hb_products')->whereIn('product_id',$gid)->pluck('hourly_cost');
		return array("hourlyprice" => $hour);
	}
}
add_hook('ClientAreaPageCart', 1, 'get_productIDs_for_specified_groups_hook');
?>

 

and placed this in the template file (tpl)

$hourlyprice

but instead of displaying the database value it just displays Array in the tpl, also I want it to fetch the data for universal use within the whmcs templates, not just a single template.

 

any help would be appreciated.

Link to comment
Share on other sites

pluck() returns an array. In your case an array with auto index therefore {$hourlyprice.0} will return your value.

That said, if you already know that the first match is okay or if you expect the query to return one value, use first() instead of pluck(). This way {hourlyprice} contains your value.

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