Re: [PHP-DB] best way to stare true, false

2002-08-12 Thread leo g. divinagracia iii

if you are storing a bunch of T/F, you can store 8 of them into a single
byte...  each bit position will represent one "question"...

you just have to do some BIT manipulation on your end...

andy wrote:

> Hi there,
>
> I am searching for the best way to store true or false inside a MySQL DB.
> With best I mean the most data efficient way and in the same time the best
> for fast searching later on the table to find all which are false, or true.
> I think I did read something about a way to do this with ENUM, but cant
> remember where and how, all tryes did not succeeed so far.
>
>

--
Leo G. Divinagracia III
[EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] best way to stare true, false

2002-08-11 Thread Jim Hunter

The smallest amount of database storage is going to be with a TinyInt and if
you set up two constants to represent TRUE and FALSE then all your code will
read correctly and will store correctly. EG:

define("TRUE", 1);
define("FALSE", 0);

now you can use TRUE and FALSE in your program where you would use any
variable (just don't use a dollar sign in front of them). This will make
your code much easier to read in the long run. Plus, if you create a 'master
global' file with all of your custom routines that you use in all programs,
you could have these globals there as well avaialable to all your programs
without thinking about it again.

Remember, keep your code readable, runable and reusable!

Jim Hunter
Diamond Computing




---Original Message---

From: andy
Date: Saturday, August 10, 2002 07:40:19 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] best way to stare true, false

Hi there,

I am searching for the best way to store true or false inside a MySQL DB.
With best I mean the most data efficient way and in the same time the best
for fast searching later on the table to find all which are false, or true.
I think I did read something about a way to do this with ENUM, but cant
remember where and how, all tryes did not succeeed so far.

Thanx for any help on that.

Andy



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

.


RE: [PHP-DB] best way to stare true, false

2002-08-11 Thread Mark Middleton

Andy,

I do use the "ENUM" technique quite a bit, with good results.

it's even easier if you set the ENUM values to 1 and 0, then when you do a
database query, you don't have to read the string, you can simply check for
it's presence.

Here's a fictitious example:

In user_table, make a field for "is_admin" ENUM('0','1')

then when you do a SQL query:

SELECT
*
FROM
user_table
WHERE
username = '$username'

do a query, and mysql_fetch_object (or however you get your DB query
results)

if ($row->is_admin) {
// This code will only be executed
// if the is_admin field is set to "1"
... code ...
}

I use phpMyAdmin to adminster the DB.  To setup an ENUM field in phpMyAdmin,
you select ENUM from the dropdown box in the column "TYPE", and place the
possible values in the "Length/Values" - for the above example, you would
simply type '0','1' in the values text box.  (I'm sorry if I'm being
redundant with info you already know, I just remember it being confusing for
me when I set up my first enum field)

I hope this helps,
Mark


> in this direction, but .. hey does nobody do this like that??
>

> > > > > I am searching for the best way to store true or false inside
> > > > > a MySQL DB. With best I mean the most data efficient way and
> > > > > in the same time the best for fast searching later on the
> > > > > table to find all which are false, or true. I think I did read
> > > > > something about a way to do this with ENUM, but cant remember
> > > > > where and how, all tryes did not succeeed so far.
> > > > >
> > > > > Thanx for any help on that.
> > > > >

>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] best way to stare true, false

2002-08-11 Thread Andy

oh... no I ment it in a different way..

somehow.. declare 1 enum value and then set it or not. Search for NULL or
not NULL values instead of false /true.

in this direction, but .. hey does nobody do this like that??

Andy

--

http://www.globosapiens.net
Global Travellers Network!



"Raquel Rice" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Sat, 10 Aug 2002 17:41:56 +0200
> "andy" <[EMAIL PROTECTED]> wrote:
>
> > > > Hi there,
> > > >
> > > > I am searching for the best way to store true or false inside
> > > > a MySQL DB. With best I mean the most data efficient way and
> > > > in the same time the best for fast searching later on the
> > > > table to find all which are false, or true. I think I did read
> > > > something about a way to do this with ENUM, but cant remember
> > > > where and how, all tryes did not succeeed so far.
> > > >
> > > > Thanx for any help on that.
> > > >
> > > > Andy
> > >
> > > How about as a "tinyint" ... 0/1
> > >
> > > --
> > > Raquel
> >
> > hmm.. thats how I am doing it right now. There might be a better
> > way?!
>
> I've never used ENUM, so take what I say with a grain of salt.  It
> appears to me that if you use "true" or "false" as your ENUM values,
> those values are stored as strings.  In PHP you would then have to
> do string comparisons rather that
> "if ($a) {
> do this;
> }"
>
> Perhaps it depends upon how you use it ... what you do with it?
>
> --
> Raquel
> 
> The world is not good enough - we must make it better.
>   --Alice Walker
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] best way to stare true, false

2002-08-10 Thread Raquel Rice

On Sat, 10 Aug 2002 17:41:56 +0200
"andy" <[EMAIL PROTECTED]> wrote:

> > > Hi there,
> > >
> > > I am searching for the best way to store true or false inside
> > > a MySQL DB. With best I mean the most data efficient way and
> > > in the same time the best for fast searching later on the
> > > table to find all which are false, or true. I think I did read
> > > something about a way to do this with ENUM, but cant remember
> > > where and how, all tryes did not succeeed so far.
> > >
> > > Thanx for any help on that.
> > >
> > > Andy
> >
> > How about as a "tinyint" ... 0/1
> >
> > --
> > Raquel
> 
> hmm.. thats how I am doing it right now. There might be a better
> way?!

I've never used ENUM, so take what I say with a grain of salt.  It
appears to me that if you use "true" or "false" as your ENUM values,
those values are stored as strings.  In PHP you would then have to
do string comparisons rather that 
"if ($a) {
do this;
}"

Perhaps it depends upon how you use it ... what you do with it?

-- 
Raquel

The world is not good enough - we must make it better.
  --Alice Walker


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] best way to stare true, false

2002-08-10 Thread andy

hmm.. thats how I am doing it right now. There might be a better way?!





"Raquel Rice" <[EMAIL PROTECTED]> schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Sat, 10 Aug 2002 16:46:54 +0200
> "andy" <[EMAIL PROTECTED]> wrote:
>
> > Hi there,
> >
> > I am searching for the best way to store true or false inside a
> > MySQL DB. With best I mean the most data efficient way and in the
> > same time the best for fast searching later on the table to find
> > all which are false, or true. I think I did read something about a
> > way to do this with ENUM, but cant remember where and how, all
> > tryes did not succeeed so far.
> >
> > Thanx for any help on that.
> >
> > Andy
>
> How about as a "tinyint" ... 0/1
>
> --
> Raquel
> 
> The world is not good enough - we must make it better.
>   --Alice Walker
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-DB] best way to stare true, false

2002-08-10 Thread Raquel Rice

On Sat, 10 Aug 2002 16:46:54 +0200
"andy" <[EMAIL PROTECTED]> wrote:

> Hi there,
> 
> I am searching for the best way to store true or false inside a
> MySQL DB. With best I mean the most data efficient way and in the
> same time the best for fast searching later on the table to find
> all which are false, or true. I think I did read something about a
> way to do this with ENUM, but cant remember where and how, all
> tryes did not succeeed so far.
> 
> Thanx for any help on that.
> 
> Andy

How about as a "tinyint" ... 0/1

-- 
Raquel

The world is not good enough - we must make it better.
  --Alice Walker


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-DB] best way to stare true, false

2002-08-10 Thread andy

Hi there,

I am searching for the best way to store true or false inside a MySQL DB.
With best I mean the most data efficient way and in the same time the best
for fast searching later on the table to find all which are false, or true.
I think I did read something about a way to do this with ENUM, but cant
remember where and how, all tryes did not succeeed so far.

Thanx for any help on that.

Andy



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php