Re: logic operands problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Merlin Morgenstern wrote:
You have described the problem very well. This is exactly where I can not find a solution.

the page number translates to the following: 1= first page 2= following pages 3= all pages

This are the options a user has while booking a product on my site. Now if ther is a new client that wants to book all pages, I need to query the table to find out if the spot is available. The spot would be full if page 1 has more results then 3 , OR all following pages have more then 3 results. So to find out if "all pages" option would be available I need to query the db to retrieve all results, that are (page = 3) OR (page = 1 XOR 2)

Am I wrong?

Yes I think you are! And XOR may be wrong here. XOR is a binary operator, so think of the number as 0b0011 for 3 0b0010 for 2 and 0b0001 for 1 ...
1 XOR 2 will give a result of 0b0011 - so = 3

What you are trying to do just seems wrong in general.
'if page 1 has more results then 3' requires you count the number of page 1 records and compare with the number of page 3 records. And the same with page 2 results.

I don't think you are giving enough detail to know exactly what you are trying to achieve, but what you are describing so far does not make sense 'logically'. If you are trying to book a 'set' of pages but can't if one of that set is already booked, then I don't think you can do this with a single query. You need to check each 'page' individually. If this was room booking, then one would have to check there are no other bookings for a day in the period for that particular room. Or putting it another way, there are no days in the period when all rooms are booked, but in this case you still need to know that a particular room is available for the whole period.

--
Lester Caine - G8HFL
-----------------------------
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux