We help IT Professionals succeed at work.

FuelPhp ORM framework to run query correctly

Jazzy 1012
Jazzy 1012 asked
on
52 Views
Last Modified: 2018-02-06
I have this function

function getSitesCount($objects){

	$sites_count = DB::select()->from('sites')
	->as_object('Model_site')
	->where('user_id', $objects->current_user->id)
	->execute();

	$id =$objects->current_user->id;
	if ($sites_count == false) return 0;

	$script = "select count(*) as count from sites where ";
	$script .= " user_id = '$id'";
	
	//echo $script;die;
	$data = DB::query($script)->execute();

	if($data == false) return 0;
	else return $data;
}

Open in new window


I want the outcome of this function to give me this query outcome:
select count(*) as count from sites where user_id like '45'

Open in new window

Which the count is "2" I want the outcome to be 2, Im using FuelPhp ORM frame work, but is there anyway anyone could help me
Comment
Watch Question

Most Valuable Expert 2011
Author of the Year 2014
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
it didnt work
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION

Author

Commented:
I solved it how I stated above however, inorder to solve the ID issue I used the experts way by creating a variable for it.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.