Answer the question
In order to leave comments, you need to log in
Does the code run on inheritance?
Hello!
Recently, I just started hacking OOP, so a couple of small questions (the code is approximate everywhere):
the first piece
class a{
function __consruct()
{
// тут запрос вида update
}
}
class b extends a{
# код
}
use a;
class b{
# код
}
Answer the question
In order to leave comments, you need to log in
no database queries can be made
in the constructor - let's start with this. the constructor is used to instantiate the class, if possible, there is no need to have any logic there at all (with the exception of passing parameters, for which separate set methods must also be implemented).
Any constructions in the constructor complicates debugging, makes the class opaque, difficult to maintain. All logic should be in methods.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question