Re: [PHP-DB] Curious if include_once will work better than include

2004-04-13 Thread Mikhail U. Petrov
Hi!
Include_once can't include one file several times.
I think if you use include_once PHP see if that file already were
included, and don't include it one more time...
Maybe difference is time to check this...

I don't trust this fact:
KR Now will that speed things up compared to just using a plain include. I call 
$connectionSDWIS(which is in the include) 5 different times?
-- 
Best regards,
Mikhail U. Petrov
mailto:[EMAIL PROTECTED]



Tuesday, April 13, 2004, 7:52:10 PM, Karen wrote:

KR Curious about include_once versus include.
 
KR All my connection stuff is in conn.php3.
 
KR I am planning on including it at the top of the page like this:
KR include_once conn.php3;
 
KR Now will that speed things up compared to just using a plain include. I call 
$connectionSDWIS(which is in the include) 5 different times?
 
KR $data = odbc_do($connectionSDWIS,EXEC sp_SanitarySurveyLatest '$pwsno');
KR $data = odbc_do($connectionSDWIS, Select Distinct CASE ActivityStatus WHEN 'A' 
THEN 'ACTIVE' WHEN 'I' THEN 'INACTIVE' END + ' ' + CASE Convert(varchar,ActDate,107) 
WHEN 'May 05, 1955' THEN ''
KR ELSE Convert(varchar,ActDate,107) END As 'ActivityStatus' FROM Inventory Where 
PWSID='$pwsno'); 
KR $data2 = odbc_do($connectionSDWIS,Exec sp_EntryPointsWithSourcesAndPWS '$pwsno');
KR $data=odbc_do($connectionSDWIS,SELECT StateID, WSFName, TreatmentProcess, 
TreatmentObjective FROM Treatments WHERE PWS= '$pwsno' ORDER BY StateID);
KR $data = odbc_do($connectionSDWIS, SELECT CalendarYear, 
convert(varchar(12),ReceivedDate, 107), convert(varchar(12),CertifiedDate, 107) FROM 
CCRS WHERE PWS='$pwsno' ORDER BY CalendarYear Desc);


KR -
KR Do you Yahoo!?
KR Yahoo! Small Business $15K Web Design Giveaway - Enter today

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



Re: [PHP-DB] Curious if include_once will work better than include

2004-04-13 Thread Eric Girard
 Curious about include_once versus include.

 All my connection stuff is in conn.php3.

 I am planning on including it at the top of the page like this:
 include_once conn.php3;

 Now will that speed things up compared to just using a plain include. I
 call $connectionSDWIS(which is in the include) 5 different times?

IMHO the 'speed' difference between include and include_once will be
slight, probably with include_once being slower because of the overhead
needed to keep track of which files have been included already.  But this
isn't really what the question is about.  include and include_once will
not magically optimize the code for you, but if you include the same file
20 times that will be more that has to be parsed needlessly, so if you
can't keep track of your includes or if including a particular file more
than once will alter the result, than use include_once. Another
alternative is to use require() or require_once() to make sure that the
file is included.   Just my $.02,

Eric

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



RE: Re[2]: [PHP-DB] Curious if include_once will work better than include

2004-04-13 Thread Hutchins, Richard
After a 2-second search of the PHP manual...

require() and include() are identical in every way except how they handle
failure. include() produces a Warning while require() results in a Fatal
Error. In other words, don't hesitate to use require() if you want a missing
file to halt processing of the page. include() does not behave this way, the
script will continue regardless. Be sure to have an appropriate include_path
setting as well.

And..

The include_once() statement includes and evaluates the specified file
during the execution of the script. This is a behavior similar to the
include() statement, with the only difference being that if the code from a
file has already been included, it will not be included again. As the name
suggests, it will be included just once.



 -Original Message-
 From: Mikhail U. Petrov [mailto:[EMAIL PROTECTED]
 Sent: Tuesday, April 13, 2004 2:07 PM
 To: Eric Girard
 Cc: Karen Resplendo; [EMAIL PROTECTED]
 Subject: Re[2]: [PHP-DB] Curious if include_once will work better than
 include
 
 
 Hi!
 Sorry for my offtopic, but by the way,
 what's the difference between include/include_once and
 require/require_once?
 
 
 Tuesday, April 13, 2004, 10:29:14 PM, Eric wrote:
 
  Curious about include_once versus include.
 
  All my connection stuff is in conn.php3.
 
  I am planning on including it at the top of the page like this:
  include_once conn.php3;
 
  Now will that speed things up compared to just using a 
 plain include. I
  call $connectionSDWIS(which is in the include) 5 different times?
 
 EG IMHO the 'speed' difference between include and 
 include_once will be
 EG slight, probably with include_once being slower because 
 of the overhead
 EG needed to keep track of which files have been included 
 already.  But this
 EG isn't really what the question is about.  include and 
 include_once will
 EG not magically optimize the code for you, but if you 
 include the same file
 EG 20 times that will be more that has to be parsed 
 needlessly, so if you
 EG can't keep track of your includes or if including a 
 particular file more
 EG than once will alter the result, than use include_once. Another
 EG alternative is to use require() or require_once() to make 
 sure that the
 EG file is included.   Just my $.02,
 
 EG Eric
 
 
 
 -- 
 Best regards,
 Mikhail U. Petrov
 mailto:[EMAIL PROTECTED]
 
 -- 
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 

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