216 reputation
18
bio website
location
age
visits member for 2 years, 2 months
seen yesterday

Nov
4
comment How can a collection class instantiate many objects with one database call?
The constructor is public, taking an integer $id to load the object from the db. I think the core of my problem is that I want to load multiple objects with one db query. I need something that can get the data, then instantiate a bunch of the target object. But how can I give a class that power without making methods public to every class?
Nov
4
comment How can a collection class instantiate many objects with one database call?
I'm experimenting with different methods of loading and right now I have several co-existing. All of my properties are non-public, but many classes have public get/set. Sometimes I havec onstructors that take a db id for existing data and 0/null to create new. Sometimes I have a static method that can save multiple data entities at once. Sometimes I have an object save() method. This is all still pretty new to me.
Nov
2
asked How can a collection class instantiate many objects with one database call?
Aug
24
answered Having a generic data type for a database table column, is it “good” practice?
Aug
24
comment Is it good/safe OOP practice to have a method whose only purpose is to send/retrieve data from another class?
Indeed I have run into problems due to my early use of table names. Are you recommending that I pass objects as parameters to other objects' methods, rather than strings/numbers? The "client" object could then use the parameter-object's methods to manipulate it or get data out of it?
Aug
24
comment Is it good/safe OOP practice to have a method whose only purpose is to send/retrieve data from another class?
Hi, sorry for the late reply. The removeWhitespace function in my example would go through a database table and remove the whitespace from every single column. I'm not sure if it would actually make sense for it to be in a utility class, which might have to work on plain strings, database tables, and database columns. What do you think?
Aug
24
accepted Why don't inherited methods use child properties? (PHP)
Aug
23
comment What are the advantages/disadvantages of using objects as parameters to other object methods?
So your distinction is between whether the instance uses the data/functions of an object of any class, or always of an object of a certain class?
Aug
22
asked What are the advantages/disadvantages of using objects as parameters to other object methods?
Feb
25
awarded  Caucus
Jan
30
awarded  Commentator
Jan
30
comment Is it a basic principle, or highly desirable, to have class methods that return “$this” rather than a value?
I understand Returning $this returns an instance of the object that the method is a member of. And in PHP OOP I believe, as I said in my question and you say in your answer, that the instance it returns is actually the very same instance as it is... i.e. it returns not a copy of itself but itself. If I am understanding correctly.
Jan
30
revised Is it a basic principle, or highly desirable, to have class methods that return “$this” rather than a value?
added php tag
Jan
30
asked Is it a basic principle, or highly desirable, to have class methods that return “$this” rather than a value?
Oct
23
comment “Never do in code what you can get the SQL server to do well for you” - Is this a recipe for a bad design?
@skynorth If you rely on the code to make sure your keys maintain integrity, then you are removing a fundamental principle of RDBMS from the DB. That makes no sense, because then every application that accesses the DB will have to make sure to precisely replicate that functionality. Why not just let the DB handle that, since that's what it's designed for. The DB can prevent duplicate keys natively, for example.
Aug
29
comment Why don't inherited methods use child properties? (PHP)
@NickC and who said anything about "coding only with static"? My question has one static function that returns an array of objects that each have object properties. My real class has a lot more class properties and a few more static properties. The question specifically asks about static property behavior, and so I didn't include all the irrelevant class components.
Aug
19
comment Why don't inherited methods use child properties? (PHP)
@NickC then how to handle properties that should remain constant through all objects of a class but allow them to be overridden by child classes? Class constants? Is it <i>better</i> to use a factory construct rather than a static method to generate collections of objects? It seems like the static method is simpler, but I'm probably wrong.
Aug
19
revised Why don't inherited methods use child properties? (PHP)
added apology on my use of static methods and members
Aug
19
comment Why don't inherited methods use child properties? (PHP)
Why is a static member not OOP? What is it's purpose, then? The data table is a constant for all objects of the class. I guess I could just use a class constant? Also, why is my question voted down 3 times without any explanation? I guess this site doesn't appreciate new posters. Good luck with that.
Aug
19
awarded  Editor