Page 4 of 5
Re: Coding discussion
Posted: Sun Apr 14, 2013 5:43 am
by Maxine MagicFox
I want to learn it, ABSOLUTELY, but I spent a whole hour today trying to figure it out when it's for a few simple lines of code.
Well, I'll take the comparison chart and try again. :\
I had made a little progress but this chart does show me a cleaner way of doing it that I wasn't aware of. :\ Hrrrm...
I do have one question, though, and this probably seems very newbish. What is the actual explanation in simple terms for ->. I've heard "object->property" but I'm not sure I fully understand. :\ We were not introduced to it in our classes.
Re: Coding discussion
Posted: Sun Apr 14, 2013 3:04 pm
by negzee
"object->property" is the simplest description of the object operator in PHP.
You can sorta (sorta) think of it like the slashes in a URL, if that helps. Objects can have other objects as properties and you'll often see that operator chained like object->object->....
Re: Coding discussion
Posted: Sun Apr 14, 2013 6:29 pm
by Maxine MagicFox
Re: Coding discussion
Posted: Sun Apr 14, 2013 8:06 pm
by Reynard-Miri
Re: Coding discussion
Posted: Sun Apr 14, 2013 8:21 pm
by Maxine MagicFox
Ironically, Rey... that actually helped. >_>; That triggered a memory of my teacher saying that in class. Got out my old notes and figured it out. Objects are basically a clump of functions and shit like that.
Re: Coding discussion
Posted: Sun Apr 14, 2013 8:32 pm
by negzee
The precise definition of an object (in an object-oriented programming, or OOP, context) varies between languages, but the general notion of an object in most languages that have some kind of OO aspect to them is that of a container that bundles some variables and the functions (referred to as methods in PHP when part of an object) that operate on them.
In your snippet, $date is an object that is an instance of the DateTime class. Classes are essentially blueprints for making usable objects with the properties and behaviours described by that class.
$date->format(...) in your snippet is a reference to the format() method defined in the DateTime class.
The official Java tutorials site has a fairly casual and approachable , which applies to PHP as well.
Re: Coding discussion
Posted: Sun Apr 14, 2013 11:32 pm
by Maxine MagicFox
Re: Coding discussion
Posted: Sun Apr 14, 2013 11:46 pm
by negzee
The problem you're having with the second connection isn't with classes, but functions.
Re: Coding discussion
Posted: Mon Apr 15, 2013 12:08 am
by Maxine MagicFox
O_O Aw! GLOBAL!
^_^ FIXED!
*mutters* <_<; That wasn't very fun... I was so sure there was something more complicated I was doing wrong.
Anywho, though, considering you didn't say anything :3 I'm assuming I'm using the -> stuff correctly and the class is set up correctly (now that $link is set to GLOBAL)?
(BTW, XD I liked the tutorial hint treatment.)
Re: Coding discussion
Posted: Mon Apr 15, 2013 12:49 am
by Maxine MagicFox
^_^ Oh, by the way - in case I haven't said it recently, negzee. THANK YOU SO MUCH FOR THE HELP! I appreciate your teaching me like this. <_<; Sorry for being such a n00b sometimes. And everyone else, too!
Re: Coding discussion
Posted: Mon Apr 15, 2013 3:06 am
by noodles
You're welcome.
Re: Coding discussion
Posted: Sat Apr 27, 2013 1:24 pm
by Maxine MagicFox
Re: Coding discussion
Posted: Sat Apr 27, 2013 6:17 pm
by negzee
There's no mysqli equivalent to mysql_result(). The way you're doing it is perfectly fine, although I wouldn't bother to name the value of count(*), and would simply fetch_array() instead of fetch_assoc().
As for mysqli_result::free() and mysqli::close(), you generally don't try to test if they worked.
Re: Coding discussion
Posted: Tue Jun 11, 2013 9:49 pm
by Maxine MagicFox
Re: Coding discussion
Posted: Wed Jun 12, 2013 11:59 am
by Kimiko
Could it be that a different ISP has different versions of essential software installed?