Jump to content

Recommended Posts

How can I call a public function inside of another public function?  The get_primary_edge() says it's undefined, but it's just another public function in the class so shouldn't this work?

 

public function get_dynamic_edge($uid)
{
	$uid = (int)$uid;

	$sql = "(	
				SELECT 
					`users`.`id`
				FROM partners
				INNER JOIN `users`
				ON `partners`.`user_id` = `users`.`id`
				WHERE partners.friend_id = '${uid}'
				AND `approved` = 1
			)
			UNION ALL
			(
				SELECT 
					`users`.`id`
				FROM `partners`
				INNER JOIN `users`
				ON `partners`.`friend_id` = `users`.`id`
				WHERE `partners`.`user_id` = '${uid}'
				AND `approved` = 1
			)";

	$result = mysql_query($sql) or die(mysql_error());

	$i = 0;

	while (($row = mysql_fetch_assoc($result)) !== false)
	{
		$dynamic[$i] = array(
			'uid' 	=> $row['id'],
			'score' => get_primary_edge($row['id']),
		);

		$i++;
	}

	print_array($dynamic);
}

It's the critical variable in object oriented programming.  It defines the current class scope and allows you access to the current class's methods and variables (and any inherited ones).  I recommend reading that entire manual chapter that's linked above.

It's the critical variable in object oriented programming.  It defines the current class scope and allows you access to the current class's methods and variables (and any inherited ones).  I recommend reading that entire manual chapter that's linked above.

 

I will. I just made my first OOP class and I would really like to learn more about it, because I feel that it is the next step for me as a coder.

It's the critical variable in object oriented programming.  It defines the current class scope and allows you access to the current class's methods and variables (and any inherited ones).  I recommend reading that entire manual chapter that's linked above.

 

I will. I just made my first OOP class and I would really like to learn more about it, because I feel that it is the next step for me as a coder.

 

Just because your using classes does not mean your coding in OOP. It's a first step, but it's not the entire picture.

It's the critical variable in object oriented programming.  It defines the current class scope and allows you access to the current class's methods and variables (and any inherited ones).  I recommend reading that entire manual chapter that's linked above.

 

I will. I just made my first OOP class and I would really like to learn more about it, because I feel that it is the next step for me as a coder.

 

Just because your using classes does not mean your coding in OOP. It's a first step, but it's not the entire picture.

 

Hmm Interesting.  Care to explain?

It's the critical variable in object oriented programming.  It defines the current class scope and allows you access to the current class's methods and variables (and any inherited ones).  I recommend reading that entire manual chapter that's linked above.

 

I will. I just made my first OOP class and I would really like to learn more about it, because I feel that it is the next step for me as a coder.

 

Just because your using classes does not mean your coding in OOP. It's a first step, but it's not the entire picture.

 

Hmm Interesting.  Care to explain?

Well, mon frere, I wouldn't say this post was in French, n'est pas?

It's the critical variable in object oriented programming.  It defines the current class scope and allows you access to the current class's methods and variables (and any inherited ones).  I recommend reading that entire manual chapter that's linked above.

 

I will. I just made my first OOP class and I would really like to learn more about it, because I feel that it is the next step for me as a coder.

 

Just because your using classes does not mean your coding in OOP. It's a first step, but it's not the entire picture.

 

Hmm Interesting.  Care to explain?

 

Stuffing a bunch of thematically similar functions in a class isn't OOP.  If it were that simple, then why would dozens of thick books exist on the subject?

 

OOP is a completely different design methodology than procedural programming.  It revolves around encapsulating both structures and behaviors, and dynamically using them/plugging them in/swapping them at run time.

Sounds a lot more complicated than I realized.  It's not just grouping functions and calling them in a specified group?

No.  That's the first step.  That's what makes some people make the jump from "include files" to "a math library," but a math library is not OOP.  Changing pi() to math::pi() doesn't give you any benefit other than namespacing.  Being able to say $user->save() and have it dynamically decide which database to save in and recursively save its child objects is a better example.
This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.