php-general Digest 1 Mar 2009 05:39:33 -0000 Issue 5985

Topics (messages 288985 through 289002):

Re: "use strict" or similar in PHP?
        288985 by: Stuart
        288998 by: Shawn McKenzie
        288999 by: Stuart
        289000 by: Shawn McKenzie
        289001 by: Michael A. Peters

Re: A puzzler (well, for me at least)
        288986 by: Daniel Brown
        288987 by: Robert Cummings
        288988 by: Nathan Rixham
        288989 by: Nathan Rixham
        288990 by: Richard Heyes

Re: Get a list of column field names from a MS Access table
        288991 by: Jim Lucas
        288992 by: Paul M Foster
        288994 by: Andrew Ballard
        288995 by: Andrew Ballard
        289002 by: Paul M Foster

Re: How important is your Express or Web Edition database? Please weigh in--
        288993 by: Andrew Ballard

Re: [PHP-DB] How important is your Express or Web Edition database? Please 
weigh in--
        288996 by: Waynn Lue
        288997 by: Ashley Sheridan

Administrivia:

To subscribe to the digest, e-mail:
        php-general-digest-subscr...@lists.php.net

To unsubscribe from the digest, e-mail:
        php-general-digest-unsubscr...@lists.php.net

To post to the list, e-mail:
        php-gene...@lists.php.net


----------------------------------------------------------------------
--- Begin Message ---
2009/2/28 Shawn McKenzie <nos...@mckenzies.net>

> Robert Cummings wrote:
> > On Sat, 2009-02-28 at 00:11 +0000, Ashley Sheridan wrote:
> >> On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote:
> >>> On Sat, 2009-02-28 at 00:02 +0600, 9el wrote:
> >>>>
> -----------------------------------------------------------------------
> >>>> Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get
> >>>> a Free CD of Ubuntu mailed to your door without any cost. Visit :
> >>>> www.ubuntu.com
> >>>> ----------------------------------------------------------------------
> >>>>
> >>>>
> >>>> On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings <
> rob...@interjinn.com>wrote:
> >>>>
> >>>>> On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote:
> >>>>>> On Feb 27, 2009, at 6:12, Hans Schultz <h.schult...@yahoo.com>
> wrote:
> >>>>>>
> >>>>>>> Hahahah,I was thinking the same thing
> >>>>>>>>
> >>>>>> The trouble is most people mean "compile a source file to an
> >>>>>> executable binary" when they sat compile. By this measure, PHP does
> >>>>>> not compile.
> >>>>> I add the following to the top of my PHP shell scripts:
> >>>>>
> >>>>>    #!/usr/bin/php -qC
> >>>>>
> >>>>> Then I do the following:
> >>>>>
> >>>>>    chmod 775 script.php
> >>>>>
> >>>>> Then I run it as follows:
> >>>>>
> >>>>>    ./script.php
> >>>>>
> >>>>> Look... and executable binary :) Don't say it's not binary. All data
> on
> >>>>> a hard disk is binary (although I do know what you mean ;)
> >>>>
> >>>> Well you are running shell script style execution its not example of
> >>>> Compiled code or Binary
> >>>>
> >>>> The data in the file is ASCII or UTF text :)
> >>> Which are subsets of binary representation ;)
> >>>
> >>>> Compilation happens when its zendOptimized or OpCoded. Its then is
> converted
> >>>> into binary content file.
> >>> But one could probably quite easily set up a system whereby
> eAccelerator
> >>> or APC or Zend Optimizer cache bytecodes are torn from a file run
> >>> similarly. As I said in an earlier post... the line between the
> >>> definition of interpreted language and compiled language is quite
> blurry
> >>> these days.
> >>>
> >>> Cheers,
> >>> Rob.
> >>> --
> >>> http://www.interjinn.com
> >>> Application and Templating Framework for PHP
> >>>
> >>>
> >> ASCII is only a subset of binary in a pedantic, literal sense. When
> >> people say binary file, they mean one that contains characters which are
> >> outside the normal display spectrum, such as chr(0), etc.
> >
> > And the argument that PHP is not compiled requires a certain level of
> > pedantry and it is still an incorrect argument since it most certainly
> > is compiled to an intermediary virtual machine code.
> >
> > Cheers,
> > Rob.
>
> Still, in PHP $compile_time == $run_time.


I haven't been following this thread, but this caught my eye as being
completely wrong. There are distinct compile and execution phases when PHP
runs a script, and different rules apply to each. If you don't believe me
try defaulting the value of a class variable to the result of a function.

-Stuart

-- 
http://stut.net/

--- End Message ---
--- Begin Message ---
Stuart wrote:
> 2009/2/28 Shawn McKenzie <nos...@mckenzies.net>
> 
>> Robert Cummings wrote:
>>> On Sat, 2009-02-28 at 00:11 +0000, Ashley Sheridan wrote:
>>>> On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote:
>>>>> On Sat, 2009-02-28 at 00:02 +0600, 9el wrote:
>> -----------------------------------------------------------------------
>>>>>> Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live. Get
>>>>>> a Free CD of Ubuntu mailed to your door without any cost. Visit :
>>>>>> www.ubuntu.com
>>>>>> ----------------------------------------------------------------------
>>>>>>
>>>>>>
>>>>>> On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings <
>> rob...@interjinn.com>wrote:
>>>>>>> On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote:
>>>>>>>> On Feb 27, 2009, at 6:12, Hans Schultz <h.schult...@yahoo.com>
>> wrote:
>>>>>>>>> Hahahah,I was thinking the same thing
>>>>>>>> The trouble is most people mean "compile a source file to an
>>>>>>>> executable binary" when they sat compile. By this measure, PHP does
>>>>>>>> not compile.
>>>>>>> I add the following to the top of my PHP shell scripts:
>>>>>>>
>>>>>>>    #!/usr/bin/php -qC
>>>>>>>
>>>>>>> Then I do the following:
>>>>>>>
>>>>>>>    chmod 775 script.php
>>>>>>>
>>>>>>> Then I run it as follows:
>>>>>>>
>>>>>>>    ./script.php
>>>>>>>
>>>>>>> Look... and executable binary :) Don't say it's not binary. All data
>> on
>>>>>>> a hard disk is binary (although I do know what you mean ;)
>>>>>> Well you are running shell script style execution its not example of
>>>>>> Compiled code or Binary
>>>>>>
>>>>>> The data in the file is ASCII or UTF text :)
>>>>> Which are subsets of binary representation ;)
>>>>>
>>>>>> Compilation happens when its zendOptimized or OpCoded. Its then is
>> converted
>>>>>> into binary content file.
>>>>> But one could probably quite easily set up a system whereby
>> eAccelerator
>>>>> or APC or Zend Optimizer cache bytecodes are torn from a file run
>>>>> similarly. As I said in an earlier post... the line between the
>>>>> definition of interpreted language and compiled language is quite
>> blurry
>>>>> these days.
>>>>>
>>>>> Cheers,
>>>>> Rob.
>>>>> --
>>>>> http://www.interjinn.com
>>>>> Application and Templating Framework for PHP
>>>>>
>>>>>
>>>> ASCII is only a subset of binary in a pedantic, literal sense. When
>>>> people say binary file, they mean one that contains characters which are
>>>> outside the normal display spectrum, such as chr(0), etc.
>>> And the argument that PHP is not compiled requires a certain level of
>>> pedantry and it is still an incorrect argument since it most certainly
>>> is compiled to an intermediary virtual machine code.
>>>
>>> Cheers,
>>> Rob.
>> Still, in PHP $compile_time == $run_time.
> 
> 
> I haven't been following this thread, but this caught my eye as being
> completely wrong. There are distinct compile and execution phases when PHP
> runs a script, and different rules apply to each. If you don't believe me
> try defaulting the value of a class variable to the result of a function.
> 
> -Stuart
> 
Rob, I wasn't talking about time.  I was talking about they're pretty
much the same as in when they execute.

Stuart,

Great, then show the OP how he can enforce strict error checking at
compile time and halt compilation and runtime altogether.

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
2009/3/1 Shawn McKenzie <nos...@mckenzies.net>

> Stuart wrote:
> > 2009/2/28 Shawn McKenzie <nos...@mckenzies.net>
> >
> >> Robert Cummings wrote:
> >>> On Sat, 2009-02-28 at 00:11 +0000, Ashley Sheridan wrote:
> >>>> On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote:
> >>>>> On Sat, 2009-02-28 at 00:02 +0600, 9el wrote:
> >> -----------------------------------------------------------------------
> >>>>>> Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live.
> Get
> >>>>>> a Free CD of Ubuntu mailed to your door without any cost. Visit :
> >>>>>> www.ubuntu.com
> >>>>>>
> ----------------------------------------------------------------------
> >>>>>>
> >>>>>>
> >>>>>> On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings <
> >> rob...@interjinn.com>wrote:
> >>>>>>> On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote:
> >>>>>>>> On Feb 27, 2009, at 6:12, Hans Schultz <h.schult...@yahoo.com>
> >> wrote:
> >>>>>>>>> Hahahah,I was thinking the same thing
> >>>>>>>> The trouble is most people mean "compile a source file to an
> >>>>>>>> executable binary" when they sat compile. By this measure, PHP
> does
> >>>>>>>> not compile.
> >>>>>>> I add the following to the top of my PHP shell scripts:
> >>>>>>>
> >>>>>>>    #!/usr/bin/php -qC
> >>>>>>>
> >>>>>>> Then I do the following:
> >>>>>>>
> >>>>>>>    chmod 775 script.php
> >>>>>>>
> >>>>>>> Then I run it as follows:
> >>>>>>>
> >>>>>>>    ./script.php
> >>>>>>>
> >>>>>>> Look... and executable binary :) Don't say it's not binary. All
> data
> >> on
> >>>>>>> a hard disk is binary (although I do know what you mean ;)
> >>>>>> Well you are running shell script style execution its not example of
> >>>>>> Compiled code or Binary
> >>>>>>
> >>>>>> The data in the file is ASCII or UTF text :)
> >>>>> Which are subsets of binary representation ;)
> >>>>>
> >>>>>> Compilation happens when its zendOptimized or OpCoded. Its then is
> >> converted
> >>>>>> into binary content file.
> >>>>> But one could probably quite easily set up a system whereby
> >> eAccelerator
> >>>>> or APC or Zend Optimizer cache bytecodes are torn from a file run
> >>>>> similarly. As I said in an earlier post... the line between the
> >>>>> definition of interpreted language and compiled language is quite
> >> blurry
> >>>>> these days.
> >>>>>
> >>>>> Cheers,
> >>>>> Rob.
> >>>>> --
> >>>>> http://www.interjinn.com
> >>>>> Application and Templating Framework for PHP
> >>>>>
> >>>>>
> >>>> ASCII is only a subset of binary in a pedantic, literal sense. When
> >>>> people say binary file, they mean one that contains characters which
> are
> >>>> outside the normal display spectrum, such as chr(0), etc.
> >>> And the argument that PHP is not compiled requires a certain level of
> >>> pedantry and it is still an incorrect argument since it most certainly
> >>> is compiled to an intermediary virtual machine code.
> >>>
> >>> Cheers,
> >>> Rob.
> >> Still, in PHP $compile_time == $run_time.
> >
> >
> > I haven't been following this thread, but this caught my eye as being
> > completely wrong. There are distinct compile and execution phases when
> PHP
> > runs a script, and different rules apply to each. If you don't believe me
> > try defaulting the value of a class variable to the result of a function.
> >
> > -Stuart
> >
> Rob, I wasn't talking about time.  I was talking about they're pretty
> much the same as in when they execute.
>
> Stuart,
>
> Great, then show the OP how he can enforce strict error checking at
> compile time and halt compilation and runtime altogether.


Like I said I haven't been following this thread so have no idea what the
original question was. I was just pointing out that your assertion
that $compile_time == $run_time is incorrect.

As far as error checking goes the PHP engine performs syntactical checks
during compile time but due to the highly flexible nature of the language
it's not possible to do most error checking until runtime.

-Stuart

-- 
http://stut.net/

--- End Message ---
--- Begin Message ---
Stuart wrote:
> 2009/3/1 Shawn McKenzie <nos...@mckenzies.net>
> 
>> Stuart wrote:
>>> 2009/2/28 Shawn McKenzie <nos...@mckenzies.net>
>>>
>>>> Robert Cummings wrote:
>>>>> On Sat, 2009-02-28 at 00:11 +0000, Ashley Sheridan wrote:
>>>>>> On Fri, 2009-02-27 at 14:32 -0500, Robert Cummings wrote:
>>>>>>> On Sat, 2009-02-28 at 00:02 +0600, 9el wrote:
>>>> -----------------------------------------------------------------------
>>>>>>>> Use FreeOpenSourceSoftwares, Stop piracy, Let the developers live.
>> Get
>>>>>>>> a Free CD of Ubuntu mailed to your door without any cost. Visit :
>>>>>>>> www.ubuntu.com
>>>>>>>>
>> ----------------------------------------------------------------------
>>>>>>>>
>>>>>>>> On Fri, Feb 27, 2009 at 11:46 PM, Robert Cummings <
>>>> rob...@interjinn.com>wrote:
>>>>>>>>> On Fri, 2009-02-27 at 09:28 -0700, LuKreme wrote:
>>>>>>>>>> On Feb 27, 2009, at 6:12, Hans Schultz <h.schult...@yahoo.com>
>>>> wrote:
>>>>>>>>>>> Hahahah,I was thinking the same thing
>>>>>>>>>> The trouble is most people mean "compile a source file to an
>>>>>>>>>> executable binary" when they sat compile. By this measure, PHP
>> does
>>>>>>>>>> not compile.
>>>>>>>>> I add the following to the top of my PHP shell scripts:
>>>>>>>>>
>>>>>>>>>    #!/usr/bin/php -qC
>>>>>>>>>
>>>>>>>>> Then I do the following:
>>>>>>>>>
>>>>>>>>>    chmod 775 script.php
>>>>>>>>>
>>>>>>>>> Then I run it as follows:
>>>>>>>>>
>>>>>>>>>    ./script.php
>>>>>>>>>
>>>>>>>>> Look... and executable binary :) Don't say it's not binary. All
>> data
>>>> on
>>>>>>>>> a hard disk is binary (although I do know what you mean ;)
>>>>>>>> Well you are running shell script style execution its not example of
>>>>>>>> Compiled code or Binary
>>>>>>>>
>>>>>>>> The data in the file is ASCII or UTF text :)
>>>>>>> Which are subsets of binary representation ;)
>>>>>>>
>>>>>>>> Compilation happens when its zendOptimized or OpCoded. Its then is
>>>> converted
>>>>>>>> into binary content file.
>>>>>>> But one could probably quite easily set up a system whereby
>>>> eAccelerator
>>>>>>> or APC or Zend Optimizer cache bytecodes are torn from a file run
>>>>>>> similarly. As I said in an earlier post... the line between the
>>>>>>> definition of interpreted language and compiled language is quite
>>>> blurry
>>>>>>> these days.
>>>>>>>
>>>>>>> Cheers,
>>>>>>> Rob.
>>>>>>> --
>>>>>>> http://www.interjinn.com
>>>>>>> Application and Templating Framework for PHP
>>>>>>>
>>>>>>>
>>>>>> ASCII is only a subset of binary in a pedantic, literal sense. When
>>>>>> people say binary file, they mean one that contains characters which
>> are
>>>>>> outside the normal display spectrum, such as chr(0), etc.
>>>>> And the argument that PHP is not compiled requires a certain level of
>>>>> pedantry and it is still an incorrect argument since it most certainly
>>>>> is compiled to an intermediary virtual machine code.
>>>>>
>>>>> Cheers,
>>>>> Rob.
>>>> Still, in PHP $compile_time == $run_time.
>>>
>>> I haven't been following this thread, but this caught my eye as being
>>> completely wrong. There are distinct compile and execution phases when
>> PHP
>>> runs a script, and different rules apply to each. If you don't believe me
>>> try defaulting the value of a class variable to the result of a function.
>>>
>>> -Stuart
>>>
>> Rob, I wasn't talking about time.  I was talking about they're pretty
>> much the same as in when they execute.
>>
>> Stuart,
>>
>> Great, then show the OP how he can enforce strict error checking at
>> compile time and halt compilation and runtime altogether.
> 
> 
> Like I said I haven't been following this thread so have no idea what the
> original question was. I was just pointing out that your assertion
> that $compile_time == $run_time is incorrect.
> 
> As far as error checking goes the PHP engine performs syntactical checks
> during compile time but due to the highly flexible nature of the language
> it's not possible to do most error checking until runtime.
> 
> -Stuart
> 

Unfortuantely, my post was in reference to the OP's question and related
to other posts in the thread.  :-)

-- 
Thanks!
-Shawn
http://www.spidean.com

--- End Message ---
--- Begin Message ---
Stuart wrote:


As far as error checking goes the PHP engine performs syntactical checks
during compile time but due to the highly flexible nature of the language
it's not possible to do most error checking until runtime.

I don't know (or care) how to do it but I suspect that if you put all output into a buffer or object (ala DOMDocument class) you could refuse to print the document to the requesting client if any errors were thrown during the creation of the document.

DOMDocument sure makes (at least for me) code easier to read because you aren't mixing html and php.
--- End Message ---
--- Begin Message ---
On Thu, Feb 26, 2009 at 09:50, Ondrej Kulaty <kopyto...@gmail.com> wrote:
> Your answer is neither relevant nor funny. :-|

    And your response wasn't welcome.  So there, everyone's even.

-- 
</Daniel P. Brown>
daniel.br...@parasane.net || danbr...@php.net
http://www.parasane.net/ || http://www.pilotpig.net/
Unadvertised dedicated server deals, too low to print - email me to find out!

--- End Message ---
--- Begin Message ---
On Sat, 2009-02-28 at 12:35 -0500, Daniel Brown wrote:
> On Thu, Feb 26, 2009 at 09:50, Ondrej Kulaty <kopyto...@gmail.com> wrote:
> > Your answer is neither relevant nor funny. :-|
> 
>     And your response wasn't welcome.  So there, everyone's even.

I'm even?? You sure? People been telling me my entire life that I'm odd!

:)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Sat, 2009-02-28 at 12:35 -0500, Daniel Brown wrote:
On Thu, Feb 26, 2009 at 09:50, Ondrej Kulaty <kopyto...@gmail.com> wrote:
Your answer is neither relevant nor funny. :-|
    And your response wasn't welcome.  So there, everyone's even.

I'm even?? You sure? People been telling me my entire life that I'm odd!


rob, that was either funny or relevant.

--- End Message ---
--- Begin Message ---
Robert Cummings wrote:
On Sat, 2009-02-28 at 12:35 -0500, Daniel Brown wrote:
On Thu, Feb 26, 2009 at 09:50, Ondrej Kulaty <kopyto...@gmail.com> wrote:
Your answer is neither relevant nor funny. :-|
    And your response wasn't welcome.  So there, everyone's even.

I'm even?? You sure? People been telling me my entire life that I'm odd!


rob, that was either funny or relevant.

--- End Message ---
--- Begin Message ---
>>>> Your answer is neither relevant nor funny. :-|
>>>
>>>    And your response wasn't welcome.  So there, everyone's even.
>>
>> I'm even?? You sure? People been telling me my entire life that I'm odd!
>>
>
> rob, that was either funny or relevant.

Neither was that.

-- 
Richard Heyes

HTML5 Canvas graphing for Firefox, Chrome, Opera and Safari:
http://www.rgraph.org (Updated February 28th)

--- End Message ---
--- Begin Message ---
revDAVE wrote:
Newbie question:

I would like to get a list of column field names from a MS Access table and
hopefully get them returned in the ORIGINAL order (as they appear in access)

Is there a sql query I could do to get this result?




--
Thanks - RevDave
Cool @ hosting4days . com
[db-lists 09]





Since I have never tried accessing Access from PHP I did some research. I found these examples on how to access Access...

http://devzone.zend.com/article/4065-Reading-Access-Databases-with-PHP-and-PECL
http://stackoverflow.com/questions/126513/php-and-ms-access-number-of-records-returned-by-select-query

I also found this nice page:  http://php.net/manual/en/function.odbc-columns.php

what extension(s) are you using to access your DB. If it is odbc, then I see no problem accessing Access schema information.

http://php.net/manual/en/function.odbc-columns.php#81227 will show you how...

--
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

--- End Message ---
--- Begin Message ---
On Sat, Feb 28, 2009 at 12:41:12AM +0000, Ashley Sheridan wrote:

> On Fri, 2009-02-27 at 16:58 -0500, Bastien Koert wrote:

<snip>

> That'll just return an empty result set, as in empty and with no fields
> output! In MySQL you can do this:
> 
> SELECT column_name FROM information_schema.columns WHERE table_name =
> 'table_name'
> 
> this might help with doing the same for M$Access?
> 

This is the SQL standard way of doing this. Both MySQL and PostgreSQL
support it. Don't know about MSSQL. 

Paul
-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Sat, Feb 28, 2009 at 6:08 PM, Paul M Foster <pa...@quillandmouse.com> wrote:
> On Sat, Feb 28, 2009 at 12:41:12AM +0000, Ashley Sheridan wrote:
>
>> On Fri, 2009-02-27 at 16:58 -0500, Bastien Koert wrote:
>
> <snip>
>
>> That'll just return an empty result set, as in empty and with no fields
>> output! In MySQL you can do this:
>>
>> SELECT column_name FROM information_schema.columns WHERE table_name =
>> 'table_name'
>>
>> this might help with doing the same for M$Access?
>>
>
> This is the SQL standard way of doing this. Both MySQL and PostgreSQL
> support it. Don't know about MSSQL.
>
> Paul
> --
> Paul M. Foster
>

Access is not MSSQL, and I'd hardly consider it standard SQL either.
:-) To even connect to it from PHP, I think you'd need to either use a
generic ODBC library or else the COM or DOTNET libraries to use
something like Microsoft's ADO library or similar.

Andrew

--- End Message ---
--- Begin Message ---
On Sat, Feb 28, 2009 at 5:08 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:
> On Sat, 2009-02-28 at 00:40 -0500, Andrew Ballard wrote:
>> On Fri, Feb 27, 2009 at 7:41 PM, Ashley Sheridan
>> <a...@ashleysheridan.co.uk> wrote:
>> > On Fri, 2009-02-27 at 16:58 -0500, Bastien Koert wrote:
>> >> On Thu, Feb 26, 2009 at 4:01 PM, revDAVE <c...@hosting4days.com> wrote:
>> >>
>> >> > Newbie question:
>> >> >
>> >> > I would like to get a list of column field names from a MS Access table 
>> >> > and
>> >> > hopefully get them returned in the ORIGINAL order (as they appear in
>> >> > access)
>> >> >
>> >> > Is there a sql query I could do to get this result?
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > Thanks - RevDave
>> >> > Cool @ hosting4days . com
>> >> > [db-lists 09]
>> >> >
>> >> >
>> >> >
>> >> >
>> >> > --
>> >> > PHP General Mailing List (http://www.php.net/)
>> >> > To unsubscribe, visit: http://www.php.net/unsub.php
>> >> >
>> >> >
>> >> A dirty way is to query the table where 1=2 to return no results
>> >>
>> >> select * from table where 1=2
>> >>
>> > That'll just return an empty result set, as in empty and with no fields
>> > output! In MySQL you can do this:
>> >
>> > SELECT column_name FROM information_schema.columns WHERE table_name =
>> > 'table_name'
>> >
>> > this might help with doing the same for M$Access?
>> >
>> >
>> > Ash
>> > www.ashleysheridan.co.uk
>> >
>>
>> I haven't ever seen information_schema in M$ Access.
>>
>> Andrew
>>
> I guess then you could do something like this:
>
> $row_names = Array();
> $query = "SELECT TOP 1 * FROM table_name";
> $result = mssql_query($query);
> while($row = mssql_fetch_array($result))
> {
>    foreach($row as $key => $value)
>    {
>        $row_names[] = $key;
>    }
> }
>
> I know it's a little messy there with the double loop, and I'm sure we
> can get rid of the while, but I've just woken up, so I'm not too compos
> mentis just yet!
>
>
> Ash
> www.ashleysheridan.co.uk
>
>

I don't even think TOP exists in Access, but I've never tried it there either.

Andrew

--- End Message ---
--- Begin Message ---
On Sat, Feb 28, 2009 at 06:54:25PM -0500, Andrew Ballard wrote:

> On Sat, Feb 28, 2009 at 6:08 PM, Paul M Foster <pa...@quillandmouse.com>
> wrote:
> > On Sat, Feb 28, 2009 at 12:41:12AM +0000, Ashley Sheridan wrote:
> >
> >> On Fri, 2009-02-27 at 16:58 -0500, Bastien Koert wrote:
> >
> > <snip>
> >
> >> That'll just return an empty result set, as in empty and with no fields
> >> output! In MySQL you can do this:
> >>
> >> SELECT column_name FROM information_schema.columns WHERE table_name =
> >> 'table_name'
> >>
> >> this might help with doing the same for M$Access?
> >>
> >
> > This is the SQL standard way of doing this. Both MySQL and PostgreSQL
> > support it. Don't know about MSSQL.
> >
> > Paul
> > --
> > Paul M. Foster
> >
> 
> Access is not MSSQL, and I'd hardly consider it standard SQL either.
> :-) To even connect to it from PHP, I think you'd need to either use a
> generic ODBC library or else the COM or DOTNET libraries to use
> something like Microsoft's ADO library or similar.
> 

I don't know about the connection details. My point was that querying
the information_schema.columns and the like are the SQL standard way of
querying the database engine to determine the details of the database
and the tables. As I recall, MySQL had quite good tools for doing this,
and PostgreSQL didn't, until the SQL standard way of querying the
database about the database was implemented.

Paul

-- 
Paul M. Foster

--- End Message ---
--- Begin Message ---
On Sat, Feb 28, 2009 at 5:13 AM, Ashley Sheridan
<a...@ashleysheridan.co.uk> wrote:
> On Sat, 2009-02-28 at 01:04 -0500, Andrew Ballard wrote:
>> On Fri, Feb 27, 2009 at 7:32 PM, Ashley Sheridan
>> <a...@ashleysheridan.co.uk> wrote:
> I absolutely love enum datatypes; they allow you to use string values
> but internally stores them as numbers, and prevents the wrong data from
> being inserted. Much simpler than joining extra tables of values onto
> it.

Oh, I know why programmers love them. I like them for a lot of the
same reasons, but I'm enough of a DBA that I'm still not sure they are
a very good idea in a SQL database. Granted, indexes on an ENUM column
will be more useful than on SET columns, but what do you do when you
need to add a value to the list? You have to have permission to modify
the database, and you are limited to about 64 values. In some projects
that's an acceptable constraint. I tend to like auxilliary tables
better because I can easily add an admin interface to an app to allow
users with sufficient permission to add their own values as needed
without granting them access to muck around with the actual table
structure, I'm NOT limited to 64 values, and indexes work even in 1:m
(SET) cases in addition to 1:1 (ENUM) relationships.

You can't add extra fields to an ENUM to track when a value was added
to the list, whether it is no longer a valid value for new records
(since it probably can't be deleted because of referential integrity),
or any other information that might be relevant to the value. I know
these aren't needed in every case, but I generally like to plan for
extensibility if it doesn't require very much additional effort.


Andrew

--- End Message ---
--- Begin Message ---
Plus, last time I checked, adding an enum required a full rebuild of
the table, while having an auxiliary table allows it to happen much
more quickly.

Waynn

On 2/28/09, Andrew Ballard <aball...@gmail.com> wrote:
> On Sat, Feb 28, 2009 at 5:13 AM, Ashley Sheridan
> <a...@ashleysheridan.co.uk> wrote:
>> On Sat, 2009-02-28 at 01:04 -0500, Andrew Ballard wrote:
>>> On Fri, Feb 27, 2009 at 7:32 PM, Ashley Sheridan
>>> <a...@ashleysheridan.co.uk> wrote:
>> I absolutely love enum datatypes; they allow you to use string values
>> but internally stores them as numbers, and prevents the wrong data from
>> being inserted. Much simpler than joining extra tables of values onto
>> it.
>
> Oh, I know why programmers love them. I like them for a lot of the
> same reasons, but I'm enough of a DBA that I'm still not sure they are
> a very good idea in a SQL database. Granted, indexes on an ENUM column
> will be more useful than on SET columns, but what do you do when you
> need to add a value to the list? You have to have permission to modify
> the database, and you are limited to about 64 values. In some projects
> that's an acceptable constraint. I tend to like auxilliary tables
> better because I can easily add an admin interface to an app to allow
> users with sufficient permission to add their own values as needed
> without granting them access to muck around with the actual table
> structure, I'm NOT limited to 64 values, and indexes work even in 1:m
> (SET) cases in addition to 1:1 (ENUM) relationships.
>
> You can't add extra fields to an ENUM to track when a value was added
> to the list, whether it is no longer a valid value for new records
> (since it probably can't be deleted because of referential integrity),
> or any other information that might be relevant to the value. I know
> these aren't needed in every case, but I generally like to plan for
> extensibility if it doesn't require very much additional effort.
>
>
> Andrew
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

--- End Message ---
--- Begin Message ---
On Sat, 2009-02-28 at 16:08 -0800, Waynn Lue wrote:
> Plus, last time I checked, adding an enum required a full rebuild of
> the table, while having an auxiliary table allows it to happen much
> more quickly.
> 
> Waynn
> 
> On 2/28/09, Andrew Ballard <aball...@gmail.com> wrote:
> > On Sat, Feb 28, 2009 at 5:13 AM, Ashley Sheridan
> > <a...@ashleysheridan.co.uk> wrote:
> >> On Sat, 2009-02-28 at 01:04 -0500, Andrew Ballard wrote:
> >>> On Fri, Feb 27, 2009 at 7:32 PM, Ashley Sheridan
> >>> <a...@ashleysheridan.co.uk> wrote:
> >> I absolutely love enum datatypes; they allow you to use string values
> >> but internally stores them as numbers, and prevents the wrong data from
> >> being inserted. Much simpler than joining extra tables of values onto
> >> it.
> >
> > Oh, I know why programmers love them. I like them for a lot of the
> > same reasons, but I'm enough of a DBA that I'm still not sure they are
> > a very good idea in a SQL database. Granted, indexes on an ENUM column
> > will be more useful than on SET columns, but what do you do when you
> > need to add a value to the list? You have to have permission to modify
> > the database, and you are limited to about 64 values. In some projects
> > that's an acceptable constraint. I tend to like auxilliary tables
> > better because I can easily add an admin interface to an app to allow
> > users with sufficient permission to add their own values as needed
> > without granting them access to muck around with the actual table
> > structure, I'm NOT limited to 64 values, and indexes work even in 1:m
> > (SET) cases in addition to 1:1 (ENUM) relationships.
> >
> > You can't add extra fields to an ENUM to track when a value was added
> > to the list, whether it is no longer a valid value for new records
> > (since it probably can't be deleted because of referential integrity),
> > or any other information that might be relevant to the value. I know
> > these aren't needed in every case, but I generally like to plan for
> > extensibility if it doesn't require very much additional effort.
> >
> >
> > Andrew
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> 
I'm not saying it is a replacement for auxiliary tables, but in a lot of
cases, an enum works far better. Consider a column called display_status
for a set of content pages. Having an enum type for 'live' and 'draft'
is perfect, and likely not to change in the future. Using an external
table is overkill, and reducing it to a number value that you then have
to remember throughout your code doesn't make sense when the enum type
makes it more logical. At the end of the day, it is down to personal
taste, but I find a lot of good uses for enum, especially in CMS
development.


Ash
www.ashleysheridan.co.uk


--- End Message ---

Reply via email to