Re: SQL Readability.. (was Re: most powerful php editor)
| From: | Larry Garfield | Date: | Sun, 28 Jan 2007 04:27:51 +0000 |
| Subject: | Re: SQL Readability.. (was Re: most powerful php editor) | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-247902@lists.php.net to get a copy of this message | ||
On Saturday 27 January 2007 1:14 pm, Jochem Maas wrote:
> >> query builders are alot more fiddly to get 'right' than one might
> >> imagine, dealing with NULLs, booleans and dates for example (as Satyam
> >> pointed out) can be a right PITA.
> >
> > I actually almost never use native date types in the SQL database. I
> > just store unix timestamps and do the math in PHP. Dates are completely
> > unportable anyway. I also tend to use ints for booleans, too, although
> > beefing up the switch statements in the code to handle native booleans
> > should be trivial.
>
> mysql doesn't have booleans does it? at least not versions I have to use.
> with regard to date stuff, many people take the opposite approach and do
> most of the date math inside SQL - most DBs have kickass date calculation
> functions btw.
>
> and for the times when you need/want unix timestamps, mysql atleast, gives
> you UNIX_TIMSTAMP().
At least as of MySQL 4.1 (haven't played with MySQL 5 much yet), yes, MySQL
has no native boolean data type that I know of. The standard alternative is
TINYINT(1), which technically gives you values 0-9.
And yes, I agree that MySQL has fairly decent date manipulation routines. But
at work we do try for database independence when possible, so except on
specific projects we try to avoid it.
--
Larry Garfield AIM: LOLG42
larry@garfieldtech.com ICQ: 6817012
"If nature has made any one thing less susceptible than all others of
exclusive property, it is the action of the thinking power called an idea,
which an individual may exclusively possess as long as he keeps it to
himself; but the moment it is divulged, it forces itself into the possession
of every one, and the receiver cannot dispossess himself of it." -- Thomas
Jefferson