php-general Digest 8 Dec 2008 23:23:43 -0000 Issue 5834

Topics (messages 284309 through 284330):

Include directive..
        284309 by: dele454
        284311 by: Jason Pruim
        284312 by: Jochem Maas
        284313 by: German Geek

Re: PHP 5.3.0alpha3
        284310 by: Rodrigo Saboya

Re: [PHP-DEV] Re: PHP 5.3.0alpha3
        284314 by: Pierre Joye

MSSQL_CONNECT problem
        284315 by: David Stoltz
        284316 by: Dan Shirah
        284317 by: David Stoltz
        284318 by: Bastien Koert

Accounting component in PHP
        284319 by: altern
        284329 by: German Geek

Re: A MySQL Question
        284320 by: Andrew Ballard
        284322 by: Robert Cummings
        284330 by: ceo.l-i-e.com

Guidance on enhancing functionality
        284321 by: Stephen

Request to bash/jump/screw my code
        284323 by: Ryan S
        284324 by: Daniel Brown
        284325 by: Rick Pasotto
        284326 by: Rick Pasotto
        284327 by: Daniel Brown
        284328 by: Ryan S

Administrivia:

To subscribe to the digest, e-mail:
        [EMAIL PROTECTED]

To unsubscribe from the digest, e-mail:
        [EMAIL PROTECTED]

To post to the list, e-mail:
        [EMAIL PROTECTED]


----------------------------------------------------------------------
--- Begin Message ---
Hi,

I am modifying the apache config file on my domain to include the path to
the Zend Framework on a specified location outside the public folder.

So in my http.conf file i simply include the path to where the includes file
is to customise the virtual host:

[CODE]

# To customize this VirtualHost use an include file at the following
location
     Include
"/usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf"
[/CODE]

And then me.conf looks like this:
[CODE]
Include "/home/domain/apps"
Include "/home/domain/apps/models"
Include "/home/domain/apps/lib"
[/CODE]

But then i get this error:

[CODE]
Failed to generate a syntactically correct Apache configuration.
Bad configuration file located at
/usr/local/apache/conf/httpd.conf.1228614930
Error:
Configuration problem detected on line 277 of file
/usr/local/apache/conf/httpd.conf.1228614930:        : Syntax error on line
1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/me.conf:
Syntax error on line 1 of /home/domain/apps/Bootstrap.php:
/home/maineven/apps/Bootstrap.php:1: <?php> was not closed.[/CODE]

But i do have the <?php tag closed in my Bootstrap file. I dont know why it
is saying otherwise.

Please help is needed.

Thanks

-----
dee
-- 
View this message in context: 
http://www.nabble.com/Include-directive..-tp20893857p20893857.html
Sent from the PHP - General mailing list archive at Nabble.com.


--- End Message ---
--- Begin Message ---

On Dec 8, 2008, at 6:47 AM, dele454 wrote:


Hi,

I am modifying the apache config file on my domain to include the path to
the Zend Framework on a specified location outside the public folder.

So in my http.conf file i simply include the path to where the includes file
is to customise the virtual host:

[CODE]

# To customize this VirtualHost use an include file at the following
location
     Include
"/usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf"
[/CODE]

And then me.conf looks like this:
[CODE]
Include "/home/domain/apps"
Include "/home/domain/apps/models"
Include "/home/domain/apps/lib"
[/CODE]

But then i get this error:

[CODE]
Failed to generate a syntactically correct Apache configuration.
Bad configuration file located at
/usr/local/apache/conf/httpd.conf.1228614930
Error:
Configuration problem detected on line 277 of file
/usr/local/apache/conf/httpd.conf.1228614930: : Syntax error on line 1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/ me.conf:
Syntax error on line 1 of /home/domain/apps/Bootstrap.php:
/home/maineven/apps/Bootstrap.php:1: <?php> was not closed.[/CODE]

But i do have the <?php tag closed in my Bootstrap file. I dont know why it
is saying otherwise.

Would it be possible to see the entire line 277 and a few above that? most likely, it's complaining that you missed a " or ; or something simple like that...

Also, you could if it's a php file, try putting it into the doc root, and hitting the file with error logging set to the highest it can go:

IE:

<?PHP

ini_set('error_reporting', E_ALL | E_STRICT);

$a = "b";
$x = $a / $b;

?>

And with the error reporting on it would show you that $b doesn't exist... Helpful for catching errors :)



--
Jason Pruim
[EMAIL PROTECTED]
616.399.2355




--- End Message ---
--- Begin Message ---
dele454 schreef:
> Hi,
> 
> I am modifying the apache config file on my domain to include the path to
> the Zend Framework on a specified location outside the public folder.
> 
> So in my http.conf file i simply include the path to where the includes file
> is to customise the virtual host:
> 
> [CODE]
> 
> # To customize this VirtualHost use an include file at the following
> location
>      Include
> "/usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf"
> [/CODE]
> 
> And then me.conf looks like this:
> [CODE]
> Include "/home/domain/apps"
> Include "/home/domain/apps/models"
> Include "/home/domain/apps/lib"
> [/CODE]
> 
> But then i get this error:
> 
> [CODE]
> Failed to generate a syntactically correct Apache configuration.
> Bad configuration file located at

READ THE PRECEDING LINE.

here is a hint: Apache Include directives have NOTHING to do
with PHP includes.

your trying to define a PHP include_path using Apache's Include
directive, guess what ... that won't work.

additionally you seem to be trying to use Apache's Include directive
to 'include' your Bootstrap.php ... which again, won't work.

> /usr/local/apache/conf/httpd.conf.1228614930
> Error:
> Configuration problem detected on line 277 of file
> /usr/local/apache/conf/httpd.conf.1228614930:        : Syntax error on line
> 1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/me.conf:
> Syntax error on line 1 of /home/domain/apps/Bootstrap.php:
> /home/maineven/apps/Bootstrap.php:1: <?php> was not closed.[/CODE]
> 
> But i do have the <?php tag closed in my Bootstrap file. I dont know why it
> is saying otherwise.

'IT' is Apache, which doesn't undetstand your PHP code to be anything
that resembles valid Apache config syntax. Apache sees '<?php'  in the [conf]
file you give it and it tries to parse this as a Directive 'tag' which it
obviously fails to do.

> Please help is needed.

I concur.

> Thanks
> 
> -----
> dee


--- End Message ---
--- Begin Message ---
On Tue, Dec 9, 2008 at 12:47 AM, dele454 <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I am modifying the apache config file on my domain to include the path to
> the Zend Framework on a specified location outside the public folder.
>
> So in my http.conf file i simply include the path to where the includes
> file
> is to customise the virtual host:
>
> [CODE]
>
> # To customize this VirtualHost use an include file at the following
> location
>     Include
> "/usr/local/apache/conf/userdata/std/2/domains/mydomain.co.za/me.conf"
> [/CODE]
>
> And then me.conf looks like this:
> [CODE]
> Include "/home/domain/apps"
> Include "/home/domain/apps/models"
> Include "/home/domain/apps/lib"
> [/CODE]
>
> But then i get this error:
>
> [CODE]
> Failed to generate a syntactically correct Apache configuration.
> Bad configuration file located at
> /usr/local/apache/conf/httpd.conf.1228614930
> Error:
> Configuration problem detected on line 277 of file
> /usr/local/apache/conf/httpd.conf.1228614930:        : Syntax error on line
> 1 of /usr/local/apache/conf/userdata/std/2/domain/mydomain.co.za/me.conf:
> Syntax error on line 1 of /home/domain/apps/Bootstrap.php:
> /home/maineven/apps/Bootstrap.php:1: <?php> was not closed.[/CODE]
>

You get this error because you are trying to include a php file in the
apache configuration. Apache config files have tags, such as <Directory> and
<?php looks like it's opening an Apache directive but not closing it with
<?php> ... </?php>

If you want to include php scripts in your php file, you should do that
there, e.g. in incfiles.php:
<?php
require_once('file1.php');
require_once('file2.php');
...

Or if you want to include a whole directory, read it with readdir (would
have to look up the function name etc) and iterate over it.

If you have classes you can also use the feature that i really like, called
class autoloading ( http://nz2.php.net/autoload ).

--- End Message ---
--- Begin Message ---
Lukas Kahwe Smith wrote:
Hello!

Johannes has packaged PHP 5.3.0alpha3, which you can find here:
http://downloads.php.net/johannes/

Windows binaries thanks to Pierre, which are available here:
http://windows.php.net/qa/

Please test it carefully, and report any bugs in the bug system, but only if you have a short reproducable test case.

It seems unlikely that we will be able to release a beta this year. However we currently do not plan another alpha release unless we find larger issues in the namespace changes. Please also note that the documentation for namespaces has been updated already:
http://php.net/namespace

regards,
Johannes and Lukas

All links at http://windows.php.net/qa/ are 404.

--
Rodrigo Saboya

--- End Message ---
--- Begin Message ---
hi!

On Mon, Dec 8, 2008 at 12:50 PM, Rodrigo Saboya
<[EMAIL PROTECTED]> wrote:

> All links at http://windows.php.net/qa/ are 404.

Fixed, the files were there but a change I made in the scripts was
setting the wrong directory. Thanks for the head up!

Cheers,
-- 
Pierre

http://blog.thepimp.net | http://www.libgd.org

--- End Message ---
--- Begin Message ---
Folks,

Can't seem to connect with MSSQL_CONNECT. The function IS available. I'm
in a Windows environment, connecting to a SQL 2000 instance. My code:

mssql_connect('INTRA_SQL,1433', 'uname', 'password');
mssql_select_db('database');

I've tried leaving the port out, tried using server IP address, all to
no avail. I've copied the "ntwdblib.dll" from my SQL 2000 box to my PHP
directory on the web server - no go. (this was suggested on the php
site).

mssql.secure_connection = off (in the php.ini file)
extension=php_mssql.dll (is also included in the ini file)

Keep getting error message: Unable to connect to server

Does anyone have any ideas?

Thanks!
Dave

--- End Message ---
--- Begin Message ---
>
> Can't seem to connect with MSSQL_CONNECT. The function IS available. I'm
> in a Windows environment, connecting to a SQL 2000 instance. My code:
>
> mssql_connect('INTRA_SQL,1433', 'uname', 'password');
> mssql_select_db('database');
>
> I've tried leaving the port out, tried using server IP address, all to
> no avail. I've copied the "ntwdblib.dll" from my SQL 2000 box to my PHP
> directory on the web server - no go. (this was suggested on the php
> site).
>
> mssql.secure_connection = off (in the php.ini file)
> extension=php_mssql.dll (is also included in the ini file)
>
> Keep getting error message: Unable to connect to server
>
> Does anyone have any ideas?
>
> Thanks!
> Dave


Dave,

For my connection I didn't copy the ntwdblib.dll file from the SQL Server
and paste it onto the PHP server...I believe there was an older version of
the ntwdblib.dll that I had to download...the file had a modification date
of I think 11/2003.

Things to check.

extension=php_mssql.dll uncommented in your PHP.ini

See if your PHP server can talk to your SQL Server.  I would assume they are
both inside the DMZ and that your DNS resolves the server names, correct?

When making your connection try doing it like this:

//Assign the server connection to a variable
$connect = mssql_connect('SERVERNAME, 'USERNAME', 'PASSWORD');

//Select your database and reference the connection
mssql_select_db('DATABASE', $connection);

--- End Message ---
--- Begin Message ---
Hi Dan,

Yes, I have:
extension=php_mssql.dll uncommented

I am using dll version "2000.80.194.0" which seems to be recommended for 
connection problems like this...

And yes - this web server talks to the SQL server on other pages using 
ASP....it seems to just be a PHP connection problem.....


Still stuck......


From: Dan Shirah [mailto:[EMAIL PROTECTED] 
Sent: Monday, December 08, 2008 9:46 AM
To: David Stoltz
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] MSSQL_CONNECT problem

Can't seem to connect with MSSQL_CONNECT. The function IS available. I'm
in a Windows environment, connecting to a SQL 2000 instance. My code:

mssql_connect('INTRA_SQL,1433', 'uname', 'password');
mssql_select_db('database');

I've tried leaving the port out, tried using server IP address, all to
no avail. I've copied the "ntwdblib.dll" from my SQL 2000 box to my PHP
directory on the web server - no go. (this was suggested on the php
site).

mssql.secure_connection = off (in the php.ini file)
extension=php_mssql.dll (is also included in the ini file)

Keep getting error message: Unable to connect to server

Does anyone have any ideas?

Thanks!
Dave
 
Dave,
 
For my connection I didn't copy the ntwdblib.dll file from the SQL Server and 
paste it onto the PHP server...I believe there was an older version of the 
ntwdblib.dll that I had to download...the file had a modification date of I 
think 11/2003.
 
Things to check.
 
extension=php_mssql.dll uncommented in your PHP.ini
 
See if your PHP server can talk to your SQL Server.  I would assume they are 
both inside the DMZ and that your DNS resolves the server names, correct?
 
When making your connection try doing it like this:
 
//Assign the server connection to a variable
$connect = mssql_connect('SERVERNAME, 'USERNAME', 'PASSWORD');
 
//Select your database and reference the connection
mssql_select_db('DATABASE', $connection);

--- End Message ---
--- Begin Message ---
On Mon, Dec 8, 2008 at 9:45 AM, Dan Shirah <[EMAIL PROTECTED]> wrote:

> >
> > Can't seem to connect with MSSQL_CONNECT. The function IS available. I'm
> > in a Windows environment, connecting to a SQL 2000 instance. My code:
> >
> > mssql_connect('INTRA_SQL,1433', 'uname', 'password');
> > mssql_select_db('database');
> >
> > I've tried leaving the port out, tried using server IP address, all to
> > no avail. I've copied the "ntwdblib.dll" from my SQL 2000 box to my PHP
> > directory on the web server - no go. (this was suggested on the php
> > site).
> >
> > mssql.secure_connection = off (in the php.ini file)
> > extension=php_mssql.dll (is also included in the ini file)
> >
> > Keep getting error message: Unable to connect to server
> >
> > Does anyone have any ideas?
> >
> > Thanks!
> > Dave
>
>
> Dave,
>
> For my connection I didn't copy the ntwdblib.dll file from the SQL Server
> and paste it onto the PHP server...I believe there was an older version of
> the ntwdblib.dll that I had to download...the file had a modification date
> of I think 11/2003.
>
> Things to check.
>
> extension=php_mssql.dll uncommented in your PHP.ini
>
> See if your PHP server can talk to your SQL Server.  I would assume they
> are
> both inside the DMZ and that your DNS resolves the server names, correct?
>
> When making your connection try doing it like this:
>
> //Assign the server connection to a variable
> $connect = mssql_connect('SERVERNAME, 'USERNAME', 'PASSWORD');
>
> //Select your database and reference the connection
> mssql_select_db('DATABASE', $connection);
>
Have you created a mssql account to allow connetion from whereever you are
coming from?


-- 

Bastien

Cat, the other other white meat

--- End Message ---
--- Begin Message ---
Hello, guys. Could please someone recommend me component wiritten in PHP
which makes financial calculations with predefined logic? I have DB with
sales information in several tables and I need to implement business logic
that includes many rules of charging, different interest rates and so on. I
need some example at least. It seems to me that I'm trying to reinvent a
wheel. Design patterns have not helped me yet. I even do not know in where
should I look to find example implementation.

To describe better what I mean, I will show one of the terrible SQL that is
used to calculate some numbers in loop during further traversing:

SELECT r.CODE, 
        r.ORDER_NUM, 
        r.REG_DATE, 
        r.ORDER_EMAIL, 
        r.STATUS, 
        r.PRICE, 
        r.BILLING_PERCENT, 
        r.REGISTRATOR_PERCENT, 
        r.REFUND_DATE, 
        IF(r.MIDDLE_CONTRACT_PERCENT > 0, c.CANCEL_FEE * (1 - 
r.BILLING_PERCENT/100
- r.REGISTRATOR_PERCENT/100 - r.MIDDLE_CONTRACT_PERCENT/100), 
        c.CANCEL_FEE) as CANCEL_FEE, 
        IF(r.MIDDLE_CONTRACT_PERCENT > 0, c.REFUND_FEE * (1 - 
r.BILLING_PERCENT/100
- r.REGISTRATOR_PERCENT/100 - r.MIDDLE_CONTRACT_PERCENT/100), 
        c.REFUND_FEE) as REFUND_FEE, 
        IF(r.MIDDLE_CONTRACT_PERCENT > 0, COALESCE(r.REFUND_FEE, 
c.CHARGEBACK_FEE)
* (1 - r.BILLING_PERCENT/100 - r.REGISTRATOR_PERCENT/100 -
r.MIDDLE_CONTRACT_PERCENT/100), 
        COALESCE(r.REFUND_FEE, c.CHARGEBACK_FEE)) as CHARGEBACK_FEE, 
        c.PERSON_LOGIN as CLIENT, 
        r.ORDER_NAME, 
        r.ORDER_NUM, 
        r.ORDER_EMAIL, 
        r.PRICE*(1 - r.BILLING_PERCENT/100 - r.REGISTRATOR_PERCENT/100 -
IF(r.MIDDLE_CONTRACT_PERCENT IS NOT NULL, r.MIDDLE_CONTRACT_PERCENT/100, 0))
as INCOME, 
        r.PRICE*(1 - r.REGISTRATOR_PERCENT/100) as REGISTRATOR_SUM, 
        r.PRICE*r.BILLING_PERCENT/100 as BILLING_INCOME, 
        r.REFUND_TYPE, 
        r.MIDDLE_CONTRACT_PERCENT FROM SOFT_REG r, 
        SOFT_CONTRACT c, 
        SOFT_PRODUCT p 
WHERE 
        p.CODE=r.PRODUCT_CODE 
        AND p.CONTRACT_CODE=c.CODE 
        AND c.CODE=5 
        AND r.REG_DATE >= '2008-08-01 00:00:00' 
        AND r.REG_DATE <= '2008-08-02 23:59:59'

After querying this sql many other things happen to get specific results on
my page. Results of this (and other similar queries) are used in several
places on the same page. I'm totally confused with all this stuff and barely
can make the code do what I want. One of the problems is that there are even
no unit-tests to keep code tested on regressions. I make conclusion that I
need separate component with object-oriented API to have possibility of
running unit tests and to have logically structured code, which I could work
with without confusion.

ORM usage is not a solution. It would just complexify what I already have
because sometimes too many tables are joining together. But again, I don't
know what idea I can start with to manage all this.

Thanks in advance. Any suggestions will be appreciated.
-- 
View this message in context: 
http://www.nabble.com/Accounting-component-in-PHP-tp20897026p20897026.html
Sent from the PHP - General mailing list archive at Nabble.com.


--- End Message ---
--- Begin Message ---
You can do raw SQL queries with ORM as well, at least in symfony ;). An ORM
makes other, rather trivial queries a whole lot easier though and a
framework like symfony makes development of generic requirements a lot
faster and cleaner.

On Tue, Dec 9, 2008 at 4:07 AM, altern <[EMAIL PROTECTED]> wrote:

>
> Hello, guys. Could please someone recommend me component wiritten in PHP
> which makes financial calculations with predefined logic? I have DB with
> sales information in several tables and I need to implement business logic
> that includes many rules of charging, different interest rates and so on. I
> need some example at least. It seems to me that I'm trying to reinvent a
> wheel. Design patterns have not helped me yet. I even do not know in where
> should I look to find example implementation.
>
> To describe better what I mean, I will show one of the terrible SQL that is
> used to calculate some numbers in loop during further traversing:
>
> SELECT r.CODE,
>        r.ORDER_NUM,
>        r.REG_DATE,
>        r.ORDER_EMAIL,
>        r.STATUS,
>        r.PRICE,
>        r.BILLING_PERCENT,
>        r.REGISTRATOR_PERCENT,
>        r.REFUND_DATE,
>        IF(r.MIDDLE_CONTRACT_PERCENT > 0, c.CANCEL_FEE * (1 -
> r.BILLING_PERCENT/100
> - r.REGISTRATOR_PERCENT/100 - r.MIDDLE_CONTRACT_PERCENT/100),
>        c.CANCEL_FEE) as CANCEL_FEE,
>        IF(r.MIDDLE_CONTRACT_PERCENT > 0, c.REFUND_FEE * (1 -
> r.BILLING_PERCENT/100
> - r.REGISTRATOR_PERCENT/100 - r.MIDDLE_CONTRACT_PERCENT/100),
>        c.REFUND_FEE) as REFUND_FEE,
>        IF(r.MIDDLE_CONTRACT_PERCENT > 0, COALESCE(r.REFUND_FEE,
> c.CHARGEBACK_FEE)
> * (1 - r.BILLING_PERCENT/100 - r.REGISTRATOR_PERCENT/100 -
> r.MIDDLE_CONTRACT_PERCENT/100),
>        COALESCE(r.REFUND_FEE, c.CHARGEBACK_FEE)) as CHARGEBACK_FEE,
>        c.PERSON_LOGIN as CLIENT,
>        r.ORDER_NAME,
>        r.ORDER_NUM,
>        r.ORDER_EMAIL,
>        r.PRICE*(1 - r.BILLING_PERCENT/100 - r.REGISTRATOR_PERCENT/100 -
> IF(r.MIDDLE_CONTRACT_PERCENT IS NOT NULL, r.MIDDLE_CONTRACT_PERCENT/100,
> 0))
> as INCOME,
>        r.PRICE*(1 - r.REGISTRATOR_PERCENT/100) as REGISTRATOR_SUM,
>        r.PRICE*r.BILLING_PERCENT/100 as BILLING_INCOME,
>        r.REFUND_TYPE,
>        r.MIDDLE_CONTRACT_PERCENT FROM SOFT_REG r,
>        SOFT_CONTRACT c,
>        SOFT_PRODUCT p
> WHERE
>        p.CODE=r.PRODUCT_CODE
>        AND p.CONTRACT_CODE=c.CODE
>        AND c.CODE=5
>        AND r.REG_DATE >= '2008-08-01 00:00:00'
>        AND r.REG_DATE <= '2008-08-02 23:59:59'
>
> After querying this sql many other things happen to get specific results on
> my page. Results of this (and other similar queries) are used in several
> places on the same page. I'm totally confused with all this stuff and
> barely
> can make the code do what I want. One of the problems is that there are
> even
> no unit-tests to keep code tested on regressions. I make conclusion that I
> need separate component with object-oriented API to have possibility of
> running unit tests and to have logically structured code, which I could
> work
> with without confusion.
>
> ORM usage is not a solution. It would just complexify what I already have
> because sometimes too many tables are joining together. But again, I don't
> know what idea I can start with to manage all this.
>
> Thanks in advance. Any suggestions will be appreciated.
> --
> View this message in context:
> http://www.nabble.com/Accounting-component-in-PHP-tp20897026p20897026.html
> Sent from the PHP - General mailing list archive at Nabble.com.
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Tim-Hinnerk Heuer

http://www.ihostnz.com -- Web Design, Hosting and free Linux Support

--- End Message ---
--- Begin Message ---
On Sun, Dec 7, 2008 at 12:38 PM, Robert Cummings <[EMAIL PROTECTED]> wrote:
> On Sun, 2008-12-07 at 11:01 -0500, Eric Butera wrote:
>> Sounds like someone thinks they're pretty clever.  I'll never
>> understand why interviewers want to ask really odd edge case questions
>> instead of ones that really show practical knowledge.  I know that I
>> don't know the syntax to everything.  What I do know is where to find
>> it in seconds if I need it.  There's better ways of weeding out resume
>> fibbers. :)  I've never actually used EXIST before, but maybe now that
>> I've looked at it I'll find a use.
>
> Oh you'll find a use alright... on stupid esoteric interview
> questions :)
>
> Cheers,
> Rob.

I use EXISTS quite a bit for regular queries. These queries are all
roughly equivalent in what they return, but depending on the database
engine and optimizer, they may have different execution plans that
make one perform better than another:

SELECT  a.*
FROM    sometable AS a, someothertable AS b
WHERE   a.keyid = b.keyid


SELECT  a.*
FROM    sometable AS a
            INNER JOIN
        someothertable AS b
            ON  a.keyid = b.keyid



SELECT  a.*
FROM    sometable AS a
WHERE   a.keyid IN (
            SELECT  b.keyid
            FROM    someothertable AS b
        )



SELECT  a.*
FROM    sometable AS a
WHERE   EXISTS (
            SELECT  *
            FROM    someothertable AS b
            WHERE   a.keyid = b.keyid
        )


Now, I realize that in a simple contrived example like this, it is
pointless to quibble much about one over another. But in more complex
queries, especially with nested subqueries, each may have benefits in
different situations. Where I've seen EXISTS shine more is in the
reverse case, where you want to find records in one table that have no
match in another:

SELECT  a.*
FROM    sometable AS a
            LEFT OUTER JOIN
        someothertable AS b
            ON  a.keyid = b.keyid
WHERE   b.keyid IS NULL


SELECT  a.*
FROM    sometable AS a
WHERE   a.keyid NOT IN (
            SELECT  b.keyid
            FROM    someothertable AS b
        )



SELECT  a.*
FROM    sometable AS a
WHERE   NOT EXISTS (
            SELECT  *
            FROM    someothertable AS b
            WHERE   a.keyid = b.keyid
        )


Andrew

--- End Message ---
--- Begin Message ---
On Mon, 2008-12-08 at 10:19 -0500, Andrew Ballard wrote:
> On Sun, Dec 7, 2008 at 12:38 PM, Robert Cummings <[EMAIL PROTECTED]> wrote:
> > On Sun, 2008-12-07 at 11:01 -0500, Eric Butera wrote:
> >> Sounds like someone thinks they're pretty clever.  I'll never
> >> understand why interviewers want to ask really odd edge case questions
> >> instead of ones that really show practical knowledge.  I know that I
> >> don't know the syntax to everything.  What I do know is where to find
> >> it in seconds if I need it.  There's better ways of weeding out resume
> >> fibbers. :)  I've never actually used EXIST before, but maybe now that
> >> I've looked at it I'll find a use.
> >
> > Oh you'll find a use alright... on stupid esoteric interview
> > questions :)
> >
> > Cheers,
> > Rob.
> 
> I use EXISTS quite a bit for regular queries. These queries are all
> roughly equivalent in what they return, but depending on the database
> engine and optimizer, they may have different execution plans that
> make one perform better than another:
> 
> SELECT  a.*
> FROM    sometable AS a, someothertable AS b
> WHERE   a.keyid = b.keyid
> 
> 
> SELECT  a.*
> FROM    sometable AS a
>             INNER JOIN
>         someothertable AS b
>             ON  a.keyid = b.keyid
> 
> 
> 
> SELECT  a.*
> FROM    sometable AS a
> WHERE   a.keyid IN (
>             SELECT  b.keyid
>             FROM    someothertable AS b
>         )
> 
> 
> 
> SELECT  a.*
> FROM    sometable AS a
> WHERE   EXISTS (
>             SELECT  *
>             FROM    someothertable AS b
>             WHERE   a.keyid = b.keyid
>         )
> 
> 
> Now, I realize that in a simple contrived example like this, it is
> pointless to quibble much about one over another. But in more complex
> queries, especially with nested subqueries, each may have benefits in
> different situations. Where I've seen EXISTS shine more is in the
> reverse case, where you want to find records in one table that have no
> match in another:
> 
> SELECT  a.*
> FROM    sometable AS a
>             LEFT OUTER JOIN
>         someothertable AS b
>             ON  a.keyid = b.keyid
> WHERE   b.keyid IS NULL
> 
> 
> SELECT  a.*
> FROM    sometable AS a
> WHERE   a.keyid NOT IN (
>             SELECT  b.keyid
>             FROM    someothertable AS b
>         )
> 
> 
> 
> SELECT  a.*
> FROM    sometable AS a
> WHERE   NOT EXISTS (
>             SELECT  *
>             FROM    someothertable AS b
>             WHERE   a.keyid = b.keyid
>         )
> 

A good example. I guess I've just never come across a need for this
query. But still, not having come across a need does not indicate an
inability to find such syntax when necessary. That said though, someone
else mentioned earlier that maybe the job was teaching about SQL or
databases, in which case I guess a more comprehensive need for the
knowledge would be necessary beforehand :)

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


--- End Message ---
--- Begin Message ---
Presumable, the EXISTS sub-query can be optimized sometimes to just stop 
processing the sub-query and kick things back out to the outer query.



IN has to process them all and find them all.



--- End Message ---
--- Begin Message ---
I want to enhance my web site’s display of photographs.

I currently have a Gallery menu selection and that leads to a PHP script that, based on parameters will

1) Display all categories of photos
2) Display the thumbnails of a selected category
3) Display a selected picture

I have a table (MySQL) for the categories and a table for the pictures.

Now, I want to add additional menu items that will have their own functionality, the same as the gallery.

I am trying to decide what the best approach is. And I suspect I might want the functionality to be different for the menu items at some time in the future.

1) Add logic to identify the menu item, and use the same tables and script, just adding a menu selection field
2) Clone the script and tables with new names
3) Some other strategy.

I will also need to enhance my control panel, of course .

I don’t have enough experience to decide which is the better long term solution.

Thoughts?

Thanks
Stephen


--- End Message ---
--- Begin Message ---
Hello everyone,

Recently I worked on a rather decent sized project and it just went live 
yesterday.

We cannot really afford a security specialist so would appreciate it if you 
could hit our site with whatever you want to (just dont take us offline with 
something like a DDOS please) and tell us if you find any problems.

As we cannot afford to pay you for this service all we an say is thank you if 
you decide to give this a go with a few seconds or a few minutes of your time.
It should be fun though as its a jokes section and even has funny 
images/cartoons and funny vids.

The site is at http://ezee.se/funnies/index.php

Any advise is also most welcome.

Thanks in advance!
Ryan


 ------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)



      

--- End Message ---
--- Begin Message ---
On Mon, Dec 8, 2008 at 12:01 PM, Ryan S <[EMAIL PROTECTED]> wrote:
>
> We cannot really afford a security specialist so would appreciate it if you 
> could hit our site with whatever you want to (just dont take us offline with 
> something like a DDOS please) and tell us if you find any problems.

    Hey, Ryan;

    Here are a few issues:

    * When subscribing to the newsletter:
        Error: Email is invalid, please check it and try again.
        Fatal error: Cannot break/continue 1 level in
/path/to/your/site/hidden/funnies_via_email.php on line 20

    * Your output isn't cleaned up when coming from the database.  You
need to put a few stripslashes() instances in there.

    * http://www.ezee.se/funnies/funnies_recommend.php, at least when
submitting a blank report, has the following error:
        Warning: Smarty error: unable to read resource: ".tpl" in
/path/to/your/site/hidden/Smarty_2_6_9/Smarty.class.php on line 1092

    * The following places are web-directory accessible (I only
checked a few, but watch them - the images directory could easily be
spidered and all content stolen):
        http://www.ezee.se/includes/Smarty_2_6_9/
        http://www.ezee.se/includes/
        http://www.ezee.se/funnies/final_images_uploaded_folder/

    Those are only a few things I noticed in the few minutes I spent
going through.  I tried some simple SQL injection stuff, but it looks
like you're properly sanitizing.  However, typical web developer:

        http://www.ezee.se/funnies/phpinfo.php

    Makes it even easier to figure out what's what on there.  While
your upload_max_filesize and post_max_size are good to keep you from
having disk space run out from spoofed uploads, they will also limit
you on legitimate uploads.  If you want someone to upload a sound or
video file, it may exceed the limits you have on there.

-- 
</Daniel P. Brown>
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
50% Off Hosting! http://www.pilotpig.net/specials.php

--- End Message ---
--- Begin Message ---
On Mon, Dec 08, 2008 at 09:01:56AM -0800, Ryan S wrote:
> 
> Any advise is also most welcome.

'Advise' is a verb.

'Advice' is a noun.

No charge.

-- 
"I didn't understand this at first, but YOUR CONVINCING USE
 OF CAPITAL LETTERS HAS MADE IT ALL CLEAR TO ME." -- J. Nairn
    Rick Pasotto    [EMAIL PROTECTED]    http://www.niof.net

--- End Message ---
--- Begin Message ---
On Mon, Dec 08, 2008 at 09:01:56AM -0800, Ryan S wrote:
> Hello everyone,
> 
> Recently I worked on a rather decent sized project and it just went
> live yesterday.
> 
> We cannot really afford a security specialist so would appreciate it
> if you could hit our site with whatever you want to (just dont take us
> offline with something like a DDOS please) and tell us if you find any
> problems.
> 
> As we cannot afford to pay you for this service all we an say is thank
> you if you decide to give this a go with a few seconds or a few
> minutes of your time. It should be fun though as its a jokes section
> and even has funny images/cartoons and funny vids.
> 
> The site is at http://ezee.se/funnies/index.php

validator.w3.org found 109 errors and 69 warnings on the front page.

http://ezee.se/funnies/show_funny.php?id=p88&sec=1 has:

Posted by:      \' OR id != \'  On:     2008-12-08 13:24:59
\' OR id != \'

-- 
"The greatest danger to liberty today comes from...expert administrators
 exclusively concerned with what they regard as the public good."
        -- Friedrich Hayek
    Rick Pasotto    [EMAIL PROTECTED]    http://www.niof.net

--- End Message ---
--- Begin Message ---
On Mon, Dec 8, 2008 at 1:05 PM, Rick Pasotto <[EMAIL PROTECTED]> wrote:
>
> http://ezee.se/funnies/show_funny.php?id=p88&sec=1 has:
>
> Posted by:      \' OR id != \'  On:     2008-12-08 13:24:59
> \' OR id != \'

    That was me, testing for SQL injection.

-- 
</Daniel P. Brown>
http://www.parasane.net/
[EMAIL PROTECTED] || [EMAIL PROTECTED]
50% Off Hosting! http://www.pilotpig.net/specials.php

--- End Message ---
--- Begin Message ---
<Snippy> 
> Any advise is also most welcome.

'Advise' is a verb.

'Advice' is a noun.

No charge.

</Snippy>

LOL! Thanks!
Got caught by the grammar and typo police but no ticket!
Must be my lucky day!

Cheers!
R



      

--- End Message ---

Reply via email to