Afficher un message
Vieux 19/02/2008, 13h03   #6
Willem Bogaerts
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Different MSSQL output date format from the same PHP script

> SELECT * is not a good thing to use. You are much better off always
> specifying the columns.
>
> For one thing, it's very seldom you need all of the columns.


Why put columns in a table if you are not interested in them? It is
really rare and a sign of bad datase stucture if a table contains things
I do not want to select.

> But more
> importantly, what happens if someone later adds a new column to the
> table (i.e. a 5mb BLOB)?


Well, first of all, that would be me. If I would add such a column, I
would have a need for it. If that field would only be vaguely connected
to the rows in that table, it would be in an only vaguely connected table.

So what happens? I would update the mapping table and a template and I
would have an extra field on my web form. Without the need to modify the
code. That is why ORM layers exist, is it not?

> Also, if someone later deletes or renames a current column, the query
> will fail, making the problem very obvious.


On the contrary, "SELECT *" will NOT fail. Just update your ORM settings
and all of your code knows it. Your php code will be less hard-wired to
the database structure, which is a good thing.

> Otherwise you may not even
> get an error message, depending on your error settings - just incorrect
> output, which may or may not be noticed for a while.


I am getting more errors than I am happy with in such a case, I can
assure you.

Regards,
--
Willem Bogaerts

Application smith
Kratz B.V.
http://www.kratz.nl/
  Réponse avec citation
 
Page generated in 0,05073 seconds with 9 queries