Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

Also this class can activate, register and login the user. This means I should connect to DB. Is it normal?

It's up to you and your requirements. Personally I am trying to make all domain specific objects simple as possible and use it only as [Value Object][1]Value Object. So, in this case all actions such as checking for existance, creation, activation, registration etc should go to another class, for example, UserManager or similar. And in this class I will hold reference to DB and doing all SQL-queries.

Should I make $connect and $dsn variables static?

Again, it's depends from your requirements. But from my point of view -- no, you shouldn't. When you doing this you cannot have two different connections for MySQL and PostgreSQL, for example.

In any case, I suggest to change public modifier to private (or protected) for $connect, $dsn and $connected memebers. [1]: http://en.wikipedia.org/wiki/Data_transfer_object

Also this class can activate, register and login the user. This means I should connect to DB. Is it normal?

It's up to you and your requirements. Personally I am trying to make all domain specific objects simple as possible and use it only as [Value Object][1]. So, in this case all actions such as checking for existance, creation, activation, registration etc should go to another class, for example, UserManager or similar. And in this class I will hold reference to DB and doing all SQL-queries.

Should I make $connect and $dsn variables static?

Again, it's depends from your requirements. But from my point of view -- no, you shouldn't. When you doing this you cannot have two different connections for MySQL and PostgreSQL, for example.

In any case, I suggest to change public modifier to private (or protected) for $connect, $dsn and $connected memebers. [1]: http://en.wikipedia.org/wiki/Data_transfer_object

Also this class can activate, register and login the user. This means I should connect to DB. Is it normal?

It's up to you and your requirements. Personally I am trying to make all domain specific objects simple as possible and use it only as Value Object. So, in this case all actions such as checking for existance, creation, activation, registration etc should go to another class, for example, UserManager or similar. And in this class I will hold reference to DB and doing all SQL-queries.

Should I make $connect and $dsn variables static?

Again, it's depends from your requirements. But from my point of view -- no, you shouldn't. When you doing this you cannot have two different connections for MySQL and PostgreSQL, for example.

In any case, I suggest to change public modifier to private (or protected) for $connect, $dsn and $connected memebers.

Source Link

Also this class can activate, register and login the user. This means I should connect to DB. Is it normal?

It's up to you and your requirements. Personally I am trying to make all domain specific objects simple as possible and use it only as [Value Object][1]. So, in this case all actions such as checking for existance, creation, activation, registration etc should go to another class, for example, UserManager or similar. And in this class I will hold reference to DB and doing all SQL-queries.

Should I make $connect and $dsn variables static?

Again, it's depends from your requirements. But from my point of view -- no, you shouldn't. When you doing this you cannot have two different connections for MySQL and PostgreSQL, for example.

In any case, I suggest to change public modifier to private (or protected) for $connect, $dsn and $connected memebers. [1]: http://en.wikipedia.org/wiki/Data_transfer_object

lang-php

AltStyle によって変換されたページ (->オリジナル) /