You are here: Re: newbie newbie to php « PHP Programming Language « IT news, forums, messages
Re: newbie newbie to php

Posted by Jerry Stuckle on 09/04/07 11:43

The Natural Philosopher wrote:
> Rik Wasmus wrote:
>> On Tue, 04 Sep 2007 08:02:42 +0200, stiki <laptopia@gmail.com> wrote:
>>
>>> On Sep 3, 4:15 am, Erwin Moller
>>> <Since_humans_read_this_I_am_spammed_too_m...@spamyourself.com> wrote:
>>>> ELINTPimp wrote:
>>>> >> // First run ONLY - need to create table by uncommenting this
>>>> >> // Or with silent @ we can let it fail every sunsequent time ;-)
>>>>
>>>> >> $q = <<<CREATE
>>>> >> create table pix (
>>>> >> pid int primary key not null auto_increment,
>>>> >> title text,
>>>> >> imgdata longblob)
>>>> >> CREATE;
>>>> >> @mysql_query($q);
>>>>
>>>> > This makes babies cry.
>>>
>>>
>>> Can someone give an example of why this is bad programming practice?
>>> Is it because he is storing the image in the database?
>>
>>
>> It's the @, and continuing on with a query one knows for sure to
>> create an (sql) error again and again and again after the first time.
>> Never appropriate.
>
>
> well why?
>
> I mean if you want to set for the existence of the table pseudo code
> wise :-
>
> if (table doesn't exist)
> create table;
>
> seems to me about as functionally simmilar as
>
> try to create table, and ignore errors that it exists;
>
> In one case the checking is explicit at the coding level, at the other
> it is implicit with the mysql library. I doubt that the actual CPU
> cycles differ much, and yu could argue this only requires ONE call to
> the Mysql library functions, not two.
>
> It seems to me an issue of pure style. And whether the person coming
> along next says 'cunning!' or 'stupid!'

You shouldn't be creating a table if it already exists...

If you need tables, they should be created on installation. You
generally shouldn't have to create or drop tables while your program is
running. If you are, chances are you've got a design problem.

And if this is during installation, you should go ahead and show the
messages so the user knows what happened. That way if they call you
with other problems (i.e. the table structure is incorrect because it's
a duplicate table name), you have someplace to start.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация