Re: [PHP] another question on setting include paths for a project

2010-03-24 Thread Richard Quadling
On 23 March 2010 16:39, Robert P. J. Day rpj...@crashcourse.ca wrote:
 On Tue, 23 Mar 2010, Richard Quadling wrote:

 However you want to identify the location, the autoloading techniques
 will allow you to only need to identify the location once. As compared
 to every file meticulously maintaining relative links to files.

 So, for testing, would this not work?

 RunTests C:\Dev\Checkouts\PROJ\trunk\tests
 RunTests C:\Installed\PROJ\V1.1\Tests
 RunTests C:\Installed\PROJ\V2.2\Tests
 RunTests C:\Installed\PROJ\V3.3\Tests

 sort of thing?

 And in RunTests, you set the location based upon the $argv[1] (using
 the autoloader technique).

 No env_var. No include_path.

  sure, but deep down, you're still doing what i'm claiming has to be
 done at some point -- *explicitly* identifying the target location.
 you're just doing it in a different way, which is fine and might be
 what i'm after.

 rday
 --


 
 Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

 Web page:                                          http://crashcourse.ca
 Twitter:                                       http://twitter.com/rpjday
 


You could of course simply look in the entire file system for a key
file, but ... well ... maybe not!

The thing about an env_var is that it is pretty much no different to
an INI setting in this regard.

By having the setting closer to the code using it (i.e. I see the
location in the batch file used to run the testing, I see the location
in the require_once() line in the main script), it is easier to see
the location. An env_var or an ini setting is quite some distance away
from the code and may seem magical.

What I'm not sure is how you can ever get away without explicitly
declaring the location unless you always put the files in the include
path.


-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] another question on setting include paths for a project

2010-03-23 Thread Robert P. J. Day
On Mon, 22 Mar 2010, Nilesh Govindarajan wrote:

 What I do is, set the include path in the top-level bootstrapper.

 /bootstrap.php:

 set_include_path(dirname(__FILE__) . '/lib' . PATH_SEPARATOR .
 get_include_path());

 Then I load the autoloader from /lib/autoload.php at the time of bootstrap.

 /lib contains others /lib/Common, /lib/Util, etc.

 So when I say new Common_Form();, it will include /lib/Common/Form.php

  not bad, i'll look at that more closely.  but let me mention a
wrinkle i mentioned before and expand on it so folks can see what i'm
trying to do and why i was suggesting the strategy i did.

  as i said, something i've used before (in admittedly non-PHP
projects) was to require developers who checked out the code base to
set a single env variable (say, PROJ_DIR) to point at the location of
the checkout.  while someone earlier suggested that was overkill,
this approach had a major benefit for me.

  in both that earlier project and in this current PHP project, there
was the possibility of multiple code base checkouts -- perhaps the
current stable one and a newer development one.  i'm a big fan of lots
and lots of automated testing so i would write numerous scripts that
would, from the command line, test the code base.

  i want those test scripts to work equally well on the production
checkout and the development checkout, and i also don't want to be
forced to locate those test scripts in any particular directory.  i
might want a totally separate checkout for test scripts, and the
freedom to check them out wherever i want.

  quite simply, i want to be able to check out my test scripts, and
tell them *which* code base to run against.  and i see no way around
that other than to have to explicitly identify the location of the
code base to be tested, and that's what the PROJ_DIR variable was for.
using that single variable, i could reset and point at whatever
checkout i wanted to test.  and i didn't see any easier way to do it.

  i've seen lots of suggestions of very clever ways to have the
components of a single checkout know there the rest of the checkout
is, and most of them would work fine.  but it seems clear that none of
those techniques would give me the ability to do what i want above --
to arbitrarily refer to checkouts from *elsewhere* and have everything
still work.  and there's one more thing.

  to speed up coding, i've added a utils directory to the code base,
containing (you guessed it) handy-dandy little utilities.  and since
they're part of the repository, it's not hard for other parts of the
checkout to include them.  but, eventually, someone is going to start
a second, sort-of-related project, and will want to reuse some of
those utilities, and the obvious solution will be to move those
utilities out of the first project and give them their own checkout
(svn external?), and again, i don't want to lock any scripts into any
particular location.

  the single environment variable idea still seems like the obvious
solution, or maybe even more than one.  because i don't see that
there's any way to make this *completely* automated.  at some point,
if i want as much flexibility as possible, a developer who checks out
one or more of these projects has to identify what directories he
wants to work with, and all subsequent includes will work off of that.

  thoughts?  sorry for rambling on so long.

rday
--


Robert P. J. Day   Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page:  http://crashcourse.ca
Twitter:   http://twitter.com/rpjday


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



Re: [PHP] another question on setting include paths for a project

2010-03-23 Thread Richard Quadling
On 23 March 2010 13:11, Robert P. J. Day rpj...@crashcourse.ca wrote:
 On Mon, 22 Mar 2010, Nilesh Govindarajan wrote:

 What I do is, set the include path in the top-level bootstrapper.

 /bootstrap.php:

 set_include_path(dirname(__FILE__) . '/lib' . PATH_SEPARATOR .
 get_include_path());

 Then I load the autoloader from /lib/autoload.php at the time of bootstrap.

 /lib contains others /lib/Common, /lib/Util, etc.

 So when I say new Common_Form();, it will include /lib/Common/Form.php

  not bad, i'll look at that more closely.  but let me mention a
 wrinkle i mentioned before and expand on it so folks can see what i'm
 trying to do and why i was suggesting the strategy i did.

  as i said, something i've used before (in admittedly non-PHP
 projects) was to require developers who checked out the code base to
 set a single env variable (say, PROJ_DIR) to point at the location of
 the checkout.  while someone earlier suggested that was overkill,
 this approach had a major benefit for me.

  in both that earlier project and in this current PHP project, there
 was the possibility of multiple code base checkouts -- perhaps the
 current stable one and a newer development one.  i'm a big fan of lots
 and lots of automated testing so i would write numerous scripts that
 would, from the command line, test the code base.

  i want those test scripts to work equally well on the production
 checkout and the development checkout, and i also don't want to be
 forced to locate those test scripts in any particular directory.  i
 might want a totally separate checkout for test scripts, and the
 freedom to check them out wherever i want.

  quite simply, i want to be able to check out my test scripts, and
 tell them *which* code base to run against.  and i see no way around
 that other than to have to explicitly identify the location of the
 code base to be tested, and that's what the PROJ_DIR variable was for.
 using that single variable, i could reset and point at whatever
 checkout i wanted to test.  and i didn't see any easier way to do it.

  i've seen lots of suggestions of very clever ways to have the
 components of a single checkout know there the rest of the checkout
 is, and most of them would work fine.  but it seems clear that none of
 those techniques would give me the ability to do what i want above --
 to arbitrarily refer to checkouts from *elsewhere* and have everything
 still work.  and there's one more thing.

  to speed up coding, i've added a utils directory to the code base,
 containing (you guessed it) handy-dandy little utilities.  and since
 they're part of the repository, it's not hard for other parts of the
 checkout to include them.  but, eventually, someone is going to start
 a second, sort-of-related project, and will want to reuse some of
 those utilities, and the obvious solution will be to move those
 utilities out of the first project and give them their own checkout
 (svn external?), and again, i don't want to lock any scripts into any
 particular location.

  the single environment variable idea still seems like the obvious
 solution, or maybe even more than one.  because i don't see that
 there's any way to make this *completely* automated.  at some point,
 if i want as much flexibility as possible, a developer who checks out
 one or more of these projects has to identify what directories he
 wants to work with, and all subsequent includes will work off of that.

  thoughts?  sorry for rambling on so long.

 rday
 --

 
 Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

 Web page:                                          http://crashcourse.ca
 Twitter:                                       http://twitter.com/rpjday
 

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



However you want to identify the location, the autoloading techniques
will allow you to only need to identify the location once. As compared
to every file meticulously maintaining relative links to files.

So, for testing, would this not work?

RunTests C:\Dev\Checkouts\PROJ\trunk\tests
RunTests C:\Installed\PROJ\V1.1\Tests
RunTests C:\Installed\PROJ\V2.2\Tests
RunTests C:\Installed\PROJ\V3.3\Tests

sort of thing?

And in RunTests, you set the location based upon the $argv[1] (using
the autoloader technique).

No env_var. No include_path.



-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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

Re: [PHP] another question on setting include paths for a project

2010-03-23 Thread Robert P. J. Day
On Tue, 23 Mar 2010, Richard Quadling wrote:

 However you want to identify the location, the autoloading techniques
 will allow you to only need to identify the location once. As compared
 to every file meticulously maintaining relative links to files.

 So, for testing, would this not work?

 RunTests C:\Dev\Checkouts\PROJ\trunk\tests
 RunTests C:\Installed\PROJ\V1.1\Tests
 RunTests C:\Installed\PROJ\V2.2\Tests
 RunTests C:\Installed\PROJ\V3.3\Tests

 sort of thing?

 And in RunTests, you set the location based upon the $argv[1] (using
 the autoloader technique).

 No env_var. No include_path.

  sure, but deep down, you're still doing what i'm claiming has to be
done at some point -- *explicitly* identifying the target location.
you're just doing it in a different way, which is fine and might be
what i'm after.

rday
--



Robert P. J. Day   Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page:  http://crashcourse.ca
Twitter:   http://twitter.com/rpjday


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



[PHP] another question on setting include paths for a project

2010-03-22 Thread Robert P. J. Day

  to recap regarding an earlier question i asked regarding extending
include paths, i have an existing project (call it proj currently
all under a top-level directory also named proj) which can be SVN
checked out anywhere under a user's home directory.  so in my case, i
might have my svn working copy under, say,
/home/rpjday/stuff/work/proj/, and all proj-related content under
that.

  at the moment, there are some subdirs under proj/ like common and
utils and debug, and all includes or requires throughout the
working copy are currently and awkwardly of the form:

  include '../../proj/utils/somescript.php';

in short, every script that needs to include another one somewhere
else in the code structure sadly needs to know its precise relative
location.

  my proposal is to get rid of most of that by:

1) having developers set a single env var PROJ_DIR in their login
   session, reflecting wherever the heck they checked out their
   working copy to, then ...
2) having said developers uniformly extend their directly callable PHP
   scripts with something at the very top like:

  set_include_path(getenv('PROJ_DIR') . PATH_SEPARATOR . get_include_path());

not only will that let them simplify their command-line callable
scripts to say just:

  include 'utils/somescript.php';

also, as i read it, that newly-extended include path percolates down
through all PHP scripts invoked directly or indirectly from this one,
right?  so while i could add that set_include_path() to every single
PHP script everywhere in the code base, it's really only necessary to
add it to those PHP scripts that people intend to *invoke* directly --
every other script will pick it up automatically as it's called, is
that correct?  (did i phrase that meaningfully?)

  that was part one.

  the new additional complication is that some of those PHP scripts
will manually construct HTTP POST requests and ship those requests off
to PHP scripts that live under a public_html/ directory, whose
scripts might *also* want to include some of those very same utils/ or
common/ scripts but that modified include path will, of course, not
carry across a POST request, so what's the standard way to similarly
modify the include path of the scripts on the server end?

  (unsurprisingly, all those server-side PHP scripts are also part
of the entire SVN checkout just so i can keep everything in the same
place for testing.)

  so how can i have those server-side scripts extend their search
path based on, perhaps, the same environment variable?

  thoughts?

rday
--


Robert P. J. Day   Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page:  http://crashcourse.ca
Twitter:   http://twitter.com/rpjday


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



Re: [PHP] another question on setting include paths for a project

2010-03-22 Thread Richard Quadling
On 22 March 2010 14:18, Robert P. J. Day rpj...@crashcourse.ca wrote:

  to recap regarding an earlier question i asked regarding extending
 include paths, i have an existing project (call it proj currently
 all under a top-level directory also named proj) which can be SVN
 checked out anywhere under a user's home directory.  so in my case, i
 might have my svn working copy under, say,
 /home/rpjday/stuff/work/proj/, and all proj-related content under
 that.

  at the moment, there are some subdirs under proj/ like common and
 utils and debug, and all includes or requires throughout the
 working copy are currently and awkwardly of the form:

  include '../../proj/utils/somescript.php';

 in short, every script that needs to include another one somewhere
 else in the code structure sadly needs to know its precise relative
 location.

  my proposal is to get rid of most of that by:

 1) having developers set a single env var PROJ_DIR in their login
   session, reflecting wherever the heck they checked out their
   working copy to, then ...
 2) having said developers uniformly extend their directly callable PHP
   scripts with something at the very top like:

  set_include_path(getenv('PROJ_DIR') . PATH_SEPARATOR . get_include_path());

 not only will that let them simplify their command-line callable
 scripts to say just:

  include 'utils/somescript.php';

 also, as i read it, that newly-extended include path percolates down
 through all PHP scripts invoked directly or indirectly from this one,
 right?  so while i could add that set_include_path() to every single
 PHP script everywhere in the code base, it's really only necessary to
 add it to those PHP scripts that people intend to *invoke* directly --
 every other script will pick it up automatically as it's called, is
 that correct?  (did i phrase that meaningfully?)

  that was part one.

  the new additional complication is that some of those PHP scripts
 will manually construct HTTP POST requests and ship those requests off
 to PHP scripts that live under a public_html/ directory, whose
 scripts might *also* want to include some of those very same utils/ or
 common/ scripts but that modified include path will, of course, not
 carry across a POST request, so what's the standard way to similarly
 modify the include path of the scripts on the server end?

  (unsurprisingly, all those server-side PHP scripts are also part
 of the entire SVN checkout just so i can keep everything in the same
 place for testing.)

  so how can i have those server-side scripts extend their search
 path based on, perhaps, the same environment variable?

  thoughts?

 rday
 --

 
 Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

 Web page:                                          http://crashcourse.ca
 Twitter:                                       http://twitter.com/rpjday
 

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



Depending upon what is being included, an autoloader could help here.

The main payoffs for autoloading are reduced memory footprint (class
are loaded JIT) and no need for each class to know exactly where the
other classes are.

So, your main page needs to load the autoloader and the autoloader
handles the loading of the classes.

No need to change the include_path setting.



-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] another question on setting include paths for a project

2010-03-22 Thread Robert P. J. Day
On Mon, 22 Mar 2010, Richard Quadling wrote:

 Depending upon what is being included, an autoloader could help
 here.

 The main payoffs for autoloading are reduced memory footprint (class
 are loaded JIT) and no need for each class to know exactly where the
 other classes are.

 So, your main page needs to load the autoloader and the autoloader
 handles the loading of the classes.

 No need to change the include_path setting.

  ok, i'm looking at the PHP manual page for autoload, sample:

  function __autoload($class_name)
  {
require_once $class_name . '.php';
  }

and some obvious questions suggest themselves:

1) in as simple an example as above, does the include_path still
control the search?  since i'm not doing anything fancy above in terms
of specifying *where* that class is defined, it seems that i'll still
have the same problem to solve, no?

2) i'm guessing that i can make the __autoload function as
sophisticated as i want, in that i can have it consult an environment
variable to determine where to search, but i'm still unsure as to how
i can set an environment variable to be consulted on the server
side.

rday
--


Robert P. J. Day   Waterloo, Ontario, CANADA

Linux Consulting, Training and Kernel Pedantry.

Web page:  http://crashcourse.ca
Twitter:   http://twitter.com/rpjday


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



Re: [PHP] another question on setting include paths for a project

2010-03-22 Thread Nilesh Govindarajan

On 03/22/2010 07:48 PM, Robert P. J. Day wrote:


   to recap regarding an earlier question i asked regarding extending
include paths, i have an existing project (call it proj currently
all under a top-level directory also named proj) which can be SVN
checked out anywhere under a user's home directory.  so in my case, i
might have my svn working copy under, say,
/home/rpjday/stuff/work/proj/, and all proj-related content under
that.

   at the moment, there are some subdirs under proj/ like common and
utils and debug, and all includes or requires throughout the
working copy are currently and awkwardly of the form:

   include '../../proj/utils/somescript.php';

in short, every script that needs to include another one somewhere
else in the code structure sadly needs to know its precise relative
location.

   my proposal is to get rid of most of that by:

1) having developers set a single env var PROJ_DIR in their login
session, reflecting wherever the heck they checked out their
working copy to, then ...
2) having said developers uniformly extend their directly callable PHP
scripts with something at the very top like:

   set_include_path(getenv('PROJ_DIR') . PATH_SEPARATOR . get_include_path());

not only will that let them simplify their command-line callable
scripts to say just:

   include 'utils/somescript.php';

also, as i read it, that newly-extended include path percolates down
through all PHP scripts invoked directly or indirectly from this one,
right?  so while i could add that set_include_path() to every single
PHP script everywhere in the code base, it's really only necessary to
add it to those PHP scripts that people intend to *invoke* directly --
every other script will pick it up automatically as it's called, is
that correct?  (did i phrase that meaningfully?)

   that was part one.

   the new additional complication is that some of those PHP scripts
will manually construct HTTP POST requests and ship those requests off
to PHP scripts that live under a public_html/ directory, whose
scripts might *also* want to include some of those very same utils/ or
common/ scripts but that modified include path will, of course, not
carry across a POST request, so what's the standard way to similarly
modify the include path of the scripts on the server end?

   (unsurprisingly, all those server-side PHP scripts are also part
of the entire SVN checkout just so i can keep everything in the same
place for testing.)

   so how can i have those server-side scripts extend their search
path based on, perhaps, the same environment variable?

   thoughts?

rday
--


Robert P. J. Day   Waterloo, Ontario, CANADA

 Linux Consulting, Training and Kernel Pedantry.

Web page:  http://crashcourse.ca
Twitter:   http://twitter.com/rpjday




What I do is, set the include path in the top-level bootstrapper.

/bootstrap.php:

set_include_path(dirname(__FILE__) . '/lib' . PATH_SEPARATOR . 
get_include_path());


Then I load the autoloader from /lib/autoload.php at the time of bootstrap.

/lib contains others /lib/Common, /lib/Util, etc.

So when I say new Common_Form();, it will include /lib/Common/Form.php

--
Nilesh Govindarajan
Site  Server Administrator
www.itech7.com

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



Re: [PHP] another question on setting include paths for a project

2010-03-22 Thread Paul M Foster
On Mon, Mar 22, 2010 at 10:51:38AM -0400, Robert P. J. Day wrote:

 On Mon, 22 Mar 2010, Richard Quadling wrote:
 
  Depending upon what is being included, an autoloader could help
  here.
 
  The main payoffs for autoloading are reduced memory footprint (class
  are loaded JIT) and no need for each class to know exactly where the
  other classes are.
 
  So, your main page needs to load the autoloader and the autoloader
  handles the loading of the classes.
 
  No need to change the include_path setting.
 
   ok, i'm looking at the PHP manual page for autoload, sample:
 
   function __autoload($class_name)
   {
 require_once $class_name . '.php';
   }
 
 and some obvious questions suggest themselves:
 
 1) in as simple an example as above, does the include_path still
 control the search?  since i'm not doing anything fancy above in terms
 of specifying *where* that class is defined, it seems that i'll still
 have the same problem to solve, no?

Yep and yep.

 
 2) i'm guessing that i can make the __autoload function as
 sophisticated as i want, in that i can have it consult an environment
 variable to determine where to search, but i'm still unsure as to how
 i can set an environment variable to be consulted on the server
 side.
 

That's the key. You can do anything you want inside __autoload(). If you
must consult something in the environment, there are a couple of ways to
do it. First, set a variable in the $_SESSION array, and consult it in
__autoload(). Second, use a configuration file for your application.
Have it in a stable place, and read the values out of it as needed.
Consult these in your __autoload() if you like.

Paul

-- 
Paul M. Foster

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



Re: [PHP] another question on setting include paths for a project

2010-03-22 Thread la...@garfieldtech.com

On 3/22/10 10:25 AM, Paul M Foster wrote:


That's the key. You can do anything you want inside __autoload(). If you
must consult something in the environment, there are a couple of ways to
do it. First, set a variable in the $_SESSION array, and consult it in
__autoload(). Second, use a configuration file for your application.
Have it in a stable place, and read the values out of it as needed.
Consult these in your __autoload() if you like.

Paul


I'd suggest skipping __autoload() and going straight for 
spl_autoload_register(), as it does the same thing but is more flexible 
since you can then have multiple autoload callbacks if necessary.


--Larry Garfield

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



Re: [PHP] another question on setting include paths for a project

2010-03-22 Thread Richard Quadling
On 22 March 2010 15:28, la...@garfieldtech.com la...@garfieldtech.com wrote:
 On 3/22/10 10:25 AM, Paul M Foster wrote:

 That's the key. You can do anything you want inside __autoload(). If you
 must consult something in the environment, there are a couple of ways to
 do it. First, set a variable in the $_SESSION array, and consult it in
 __autoload(). Second, use a configuration file for your application.
 Have it in a stable place, and read the values out of it as needed.
 Consult these in your __autoload() if you like.

 Paul

 I'd suggest skipping __autoload() and going straight for
 spl_autoload_register(), as it does the same thing but is more flexible
 since you can then have multiple autoload callbacks if necessary.

 --Larry Garfield

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



Completely agree with Larry here. spl_autoload_register is __autoload++.

Essentially, the autoloader knows where it is and should know where
everything else it is expected to load is.

Having a naming convention that say maps class name to file path/name
(Zend_Soap_Wsdl_Exception maps to ./Zend/Soap/Wsdl/Exception.php) and
sticking with it allows for a single autoloader to be used for any
root name.

Autoloading only really works out-the-box with classes. There has been
discussion on making this work with functions and namespaces.



-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Re: [PHP] another question on setting include paths for a project

2010-03-22 Thread Richard Quadling
On 22 March 2010 14:51, Robert P. J. Day rpj...@crashcourse.ca wrote:
 On Mon, 22 Mar 2010, Richard Quadling wrote:

 Depending upon what is being included, an autoloader could help
 here.

 The main payoffs for autoloading are reduced memory footprint (class
 are loaded JIT) and no need for each class to know exactly where the
 other classes are.

 So, your main page needs to load the autoloader and the autoloader
 handles the loading of the classes.

 No need to change the include_path setting.

  ok, i'm looking at the PHP manual page for autoload, sample:

  function __autoload($class_name)
  {
    require_once $class_name . '.php';
  }

 and some obvious questions suggest themselves:

 1) in as simple an example as above, does the include_path still
 control the search?  since i'm not doing anything fancy above in terms
 of specifying *where* that class is defined, it seems that i'll still
 have the same problem to solve, no?

No. The autoloader is part of the project, so it will know its
relative pathing to the other files. __DIR__ in the autoloader will
tell the autoloader where it is and all associated files should be
relative this.

You only need to know the relative path of the autoloader.

No need to alter include_path and you can remove all those
(require|include)(_once)? lines too as the autoloader kicks in
whenever a class it requested that hasn't been loaded.


 2) i'm guessing that i can make the __autoload function as
 sophisticated as i want, in that i can have it consult an environment
 variable to determine where to search, but i'm still unsure as to how
 i can set an environment variable to be consulted on the server
 side.

I think once you've got the autoloader working, you don't need to worry.

 rday
 --

 
 Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

 Web page:                                          http://crashcourse.ca
 Twitter:                                       http://twitter.com/rpjday
 




-- 
-
Richard Quadling
Standing on the shoulders of some very clever giants!
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

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



Fwd: Re: [PHP] another question on setting include paths for a project

2010-03-22 Thread Jochem Maas
oops, mailed the OP direct rather than the list. sorry.

 Originele bericht 
Onderwerp: Re: [PHP] another question on setting include paths for a project
Datum: Mon, 22 Mar 2010 15:58:28 +
Van: Jochem Maas joc...@iamjochem.com
Aan: Robert P. J. Day rpj...@crashcourse.ca

Op 3/22/10 2:18 PM, Robert P. J. Day schreef:
 
   to recap regarding an earlier question i asked regarding extending
 include paths, i have an existing project (call it proj currently
 all under a top-level directory also named proj) which can be SVN
 checked out anywhere under a user's home directory.  so in my case, i
 might have my svn working copy under, say,
 /home/rpjday/stuff/work/proj/, and all proj-related content under
 that.
 
   at the moment, there are some subdirs under proj/ like common and
 utils and debug, and all includes or requires throughout the
 working copy are currently and awkwardly of the form:
 
   include '../../proj/utils/somescript.php';
 
 in short, every script that needs to include another one somewhere
 else in the code structure sadly needs to know its precise relative
 location.
 
   my proposal is to get rid of most of that by:
 
 1) having developers set a single env var PROJ_DIR in their login
session, reflecting wherever the heck they checked out their
working copy to, then ...
 2) having said developers uniformly extend their directly callable PHP
scripts with something at the very top like:
 
   set_include_path(getenv('PROJ_DIR') . PATH_SEPARATOR . get_include_path());
 
 not only will that let them simplify their command-line callable
 scripts to say just:
 
   include 'utils/somescript.php';
 
 also, as i read it, that newly-extended include path percolates down
 through all PHP scripts invoked directly or indirectly from this one,
 right?  so while i could add that set_include_path() to every single
 PHP script everywhere in the code base, it's really only necessary to
 add it to those PHP scripts that people intend to *invoke* directly --
 every other script will pick it up automatically as it's called, is
 that correct?  (did i phrase that meaningfully?)
 
   that was part one.
 
   the new additional complication is that some of those PHP scripts
 will manually construct HTTP POST requests and ship those requests off
 to PHP scripts that live under a public_html/ directory, whose
 scripts might *also* want to include some of those very same utils/ or
 common/ scripts but that modified include path will, of course, not
 carry across a POST request, so what's the standard way to similarly
 modify the include path of the scripts on the server end?
 
   (unsurprisingly, all those server-side PHP scripts are also part
 of the entire SVN checkout just so i can keep everything in the same
 place for testing.)
 
   so how can i have those server-side scripts extend their search
 path based on, perhaps, the same environment variable?
 
   thoughts?

I think the whole 'set an ENV var in their shell session' idea is overkill.
everything is checked out from svn, the structure of the project is known,
there is no reason not to use relative paths for the includes, there is
no need to tell the scripts where stuff is in this scenario - they can
work it out automatically.

the following might give you an idea for a bit of bootstrap code that's included
by everything:

define('INC_DIR', dirname(__FILE__));

this would allow all other code to use absolute paths and allow you to set
the include_path to ''.

how do the cmdline scripts know which URL to hit ... I would assume that this
URL can change depending on whose checkout it is and the context (dev/prod),
that means there is already a config file or some such - possibly a good place
to stick the include path or define the include dir.

... and now for something 'completey' different:

another trick I've used is to use custom ini settings in conjunction with
get_cfg_var() - each developer/installation would have their own custom ini
file (which you can store in svn too) .. the ini file would be symlinked to
from the dir php is setup to read additional ini files from, the contents of
the ini file would be something like:

[My Cool App]
my_cool_app.public_url  = 'http://local.coolapp/';
my_cool_app.inc_dir = '/path/to/cool/app/';

you can then grab these values from anywhere using 
get_cfg_var('my_cool_app.inc_dir'),
often I find that additional config stuff is needed per installation - mostly 
related
to webserver setup (which sometimes differs somewhat between live and dev 
installs -
SSL may not be available/required/wanted and if it is IP addresses need to be 
hard coded,
apache may require you to use absolute paths, test systems may require IP 
restrictions, etc)

so I setup a dir structure like so:

project/cnf/targets/localhost.jochem/php
project/cnf/targets/localhost.jochem/httpd
project/cnf/targets/localhost.charlie/php
project/cnf/targets/localhost.charlie/httpd

RE: [PHP] Another question about Google maps

2008-11-17 Thread Boyd, Todd M.
 -Original Message-
 From: tedd [mailto:[EMAIL PROTECTED]
 Sent: Saturday, November 15, 2008 2:11 PM
 To: php-general@lists.php.net
 Subject: [PHP] Another question about Google maps
 
 Hi gang:
 
 I posted this question on the Google Map Discussion group/list
 thingie, but got zip in replies. Maybe someone here might have an
 idea.
 
 Here's the url:
 
 http://masoncollision.com/contact.php
 
 In both Safari and FireFox for the Mac (I have not tested it with
 other browsers) as the page loads the map border is momentary drawn
 twice. The map border is shown stacked one above the other making the
 page much longer than it actually is. But immediately thereafter, the
 map is drawn correctly and the page returns to the size it's supposed
 to be.
 
 I just want to get rid of the momentary flash.
 
 Anyone have any ideas?

tedd, I think it might be displaying your extra divs (if there are any..
just skimmed the source momentarily) for a split second before they are
hidden with Javascript. Maybe try setting the CSS for your 3 map divs
(mapsearch, idlediv, searchdiv or whatever) to display:none and show
them when the page is loaded? Or give all 3 the same top/left
coordinates, etc...

Just a shot in the dark. I may read over the code a bit more if I get
some time later today. I'm no expert, but I've been working with the
Google Maps API rather extensively lately, and maybe I can offer a fresh
set of eyes.

HTH,


Todd Boyd
Web Programmer

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



RE: [PHP] Another question about Google maps

2008-11-17 Thread tedd

At 8:37 AM -0600 11/17/08, Boyd, Todd M. wrote:

tedd, I think it might be displaying your extra divs (if there are any..
just skimmed the source momentarily) for a split second before they are
hidden with Javascript. Maybe try setting the CSS for your 3 map divs
(mapsearch, idlediv, searchdiv or whatever) to display:none and show
them when the page is loaded? Or give all 3 the same top/left
coordinates, etc...

Just a shot in the dark. I may read over the code a bit more if I get
some time later today. I'm no expert, but I've been working with the
Google Maps API rather extensively lately, and maybe I can offer a fresh
set of eyes.

HTH,


Todd Boyd
Web Programmer


Todd:

That would be great. Also, if you see anything there you like, of 
course you may use it.


I think the div's are Okay -- I always check my code through the W3C 
validator and that does a good job of checking that. I wish that 
Google and W3C would decide on what's acceptable.


I also tried display: none via css, but could not get the right 
combination of hide/display to make it work right. However, I'll look 
into your suggestion.


If you can find anything to correct, that would be good. But it's 
just a minor annoyance and I thought someone might readily know what 
the problem was.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Another question about Google maps

2008-11-16 Thread Michael Kubler

Well, it shows up for FFox v2 and v3 on Windows XP as well.
I managed to replicate it by shift+refreshing the page.

I also managed to stop it mid load by setting Firefox to 'Work Offline' 
just as it displayed the flash of both boxes.


Using the Web Developer plugin for FFox I can tell you that the top box 
has a class of '.gsmsc-mapDiv' while the bottom div one is 
'.gsmsc-idleMapDiv', and both are wrapped in the '.gsmsc-appContainer' 
div, and also the '#mapsearch' div.


I've not played with google maps enough, but doubt the above helps, I 
just but know that it's not a PHP issue. It's almost like a flash of 
unstyled content http://www.bluerobot.com/web/css/fouc.asp/, but is 
being generated because of the javascript.


I hid the '.gsmsc-mapDiv' which stopped the flash of both box boxes 
appearing, and I could view the map, but caused the map to disappear 
after I tried searching for a different Google Maps location.


Michael Kubler
*G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz



tedd wrote:

Hi gang:

I posted this question on the Google Map Discussion group/list 
thingie, but got zip in replies. Maybe someone here might have an idea.


Here's the url:

http://masoncollision.com/contact.php

In both Safari and FireFox for the Mac (I have not tested it with 
other browsers) as the page loads the map border is momentary drawn 
twice. The map border is shown stacked one above the other making the 
page much longer than it actually is. But immediately thereafter, the 
map is drawn correctly and the page returns to the size it's supposed 
to be.


I just want to get rid of the momentary flash.

Anyone have any ideas?

Cheers and thanks,

tedd


Re: [PHP] Another question about Google maps

2008-11-16 Thread tedd

At 1:29 AM +1030 11/17/08, Michael Kubler wrote:

Well, it shows up for FFox v2 and v3 on Windows XP as well.
I managed to replicate it by shift+refreshing the page.

I also managed to stop it mid load by setting Firefox to 'Work 
Offline' just as it displayed the flash of both boxes.


Using the Web Developer plugin for FFox I can tell you that the top 
box has a class of '.gsmsc-mapDiv' while the bottom div one is 
'.gsmsc-idleMapDiv', and both are wrapped in the 
'.gsmsc-appContainer' div, and also the '#mapsearch' div.


I've not played with google maps enough, but doubt the above helps, 
I just but know that it's not a PHP issue. It's almost like a flash 
of unstyled content http://www.bluerobot.com/web/css/fouc.asp/, 
but is being generated because of the javascript.


I hid the '.gsmsc-mapDiv' which stopped the flash of both box boxes 
appearing, and I could view the map, but caused the map to disappear 
after I tried searching for a different Google Maps location.


Michael Kubler
*G*rey *P*hoenix *P*roductions http://www.greyphoenix.biz


Michael

Thanks very much for your time looking into this.

It IS very similar of FOUC and I looked into that as a possible 
problem/solution.


I think you can see why I didn't get a reply from my Google post -- 
it's one of those problems that Google has, but doesn't yet 
understand it well enough to fix it. Too busy with new stuff *.


I may have to hide the map via css and then change display after load 
-- I just didn't want to go that route IF there was a better way.


Thanks again,

tedd


PS: * I really like Google's Analytics, but hate all the javascript 
errors it generates in FF firebug.


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



[PHP] Another question about Google maps

2008-11-15 Thread tedd

Hi gang:

I posted this question on the Google Map Discussion group/list 
thingie, but got zip in replies. Maybe someone here might have an 
idea.


Here's the url:

http://masoncollision.com/contact.php

In both Safari and FireFox for the Mac (I have not tested it with 
other browsers) as the page loads the map border is momentary drawn 
twice. The map border is shown stacked one above the other making the 
page much longer than it actually is. But immediately thereafter, the 
map is drawn correctly and the page returns to the size it's supposed 
to be.


I just want to get rid of the momentary flash.

Anyone have any ideas?

Cheers and thanks,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

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



Re: [PHP] Another question about functions...

2008-01-31 Thread Jason Pruim


On Jan 30, 2008, at 7:53 PM, Richard Lynch wrote:


On Tue, January 29, 2008 1:39 pm, Jason Pruim wrote:

Okay, so I checked everything I can think of, and it's still
downloading it as an application which means it's downloading the
entire website instead of just the data from the database... Anyone
have any idea what to check?


Can you explain what you mean by downloading it as an  
application?...



I can try :) when I downloaded in clicking on the link, and tried to  
open it OS X popped on a message saying that I had downloaded an  
applicaiton and it was the first time I had tried to open it, was I  
sure that I wanted to, and I could view the web page it was downloaded  
from, go ahead and open it, or cancel.


When I tell it to open, it opens in excel, what appears to be a copy  
of the actual webpage. Including the CSS, images, my banner, and then  
as much of the actual database at it can cram into 1 cell.


What I found out though, is after I removed the doctype, and banners  
from an included file that I was able to download it as a normal excel  
file and now is working great.


I hope that explains it a little better...

And now, I just need to get my search function to work :) But that's  
another e-mail... We'll see if I get a chance to tackle it today or not.


Thanks for looking though! Your replies have always been extremely  
helpful.

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Another question about functions...

2008-01-31 Thread Zoltán Németh
2008. 01. 31, csütörtök keltezéssel 08.12-kor Jason Pruim ezt írta:
 On Jan 30, 2008, at 7:53 PM, Richard Lynch wrote:
 
  On Tue, January 29, 2008 1:39 pm, Jason Pruim wrote:
  Okay, so I checked everything I can think of, and it's still
  downloading it as an application which means it's downloading the
  entire website instead of just the data from the database... Anyone
  have any idea what to check?
 
  Can you explain what you mean by downloading it as an  
  application?...
 
 
 I can try :) when I downloaded in clicking on the link, and tried to  
 open it OS X popped on a message saying that I had downloaded an  
 applicaiton and it was the first time I had tried to open it, was I  
 sure that I wanted to, and I could view the web page it was downloaded  
 from, go ahead and open it, or cancel.
 
 When I tell it to open, it opens in excel, what appears to be a copy  
 of the actual webpage. Including the CSS, images, my banner, and then  
 as much of the actual database at it can cram into 1 cell.
 
 What I found out though, is after I removed the doctype, and banners  
 from an included file that I was able to download it as a normal excel  
 file and now is working great.

oh yeah, never put your htmlcss stuff into an excel download :)

greets
Zoltán Németh

 
 I hope that explains it a little better...
 
 And now, I just need to get my search function to work :) But that's  
 another e-mail... We'll see if I get a chance to tackle it today or not.
 
 Thanks for looking though! Your replies have always been extremely  
 helpful.
 --
 
 Jason Pruim
 Raoset Inc.
 Technology Manager
 MQC Specialist
 3251 132nd ave
 Holland, MI, 49424
 www.raoset.com
 [EMAIL PROTECTED]
 

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



Re: [PHP] Another question about functions...

2008-01-31 Thread Jason Pruim


On Jan 31, 2008, at 8:19 AM, Zoltán Németh wrote:



I can try :) when I downloaded in clicking on the link, and tried to
open it OS X popped on a message saying that I had downloaded an
applicaiton and it was the first time I had tried to open it, was I
sure that I wanted to, and I could view the web page it was  
downloaded

from, go ahead and open it, or cancel.

When I tell it to open, it opens in excel, what appears to be a copy
of the actual webpage. Including the CSS, images, my banner, and then
as much of the actual database at it can cram into 1 cell.

What I found out though, is after I removed the doctype, and banners
from an included file that I was able to download it as a normal  
excel

file and now is working great.


oh yeah, never put your htmlcss stuff into an excel download :)



Yeah.. It wasn't intentional... :) Stupid include files... Try and  
manage the settings from 1 location and get hassled for doing it! :P  
Anyway, Now I just create a visual.include file for my doctype/banner  
type stuff :)

--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Another question about functions...

2008-01-30 Thread Jason Pruim


On Jan 29, 2008, at 4:29 PM, Nathan Nobbe wrote:


On Jan 29, 2008 3:53 PM, Jason Pruim [EMAIL PROTECTED] wrote:
I did as you suggested, and I think I found the reason... I included  
info for the doctype, and some files that are on all my pages...  
Once I comment out those lines it works just fine...


I'm assuming that that is expected behavior?

where did you include this information?
i didnt see it in the original code you posted.
and, btw. im no expert on setting mime types for excel :)

-nathan





They were included in a config file I am working on... the  
defaults.php file that has other config info, such as DB auth info and  
system wide variables.



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




Re: [PHP] Another question about functions...

2008-01-30 Thread Richard Lynch
On Tue, January 29, 2008 1:39 pm, Jason Pruim wrote:
 Okay, so I checked everything I can think of, and it's still
 downloading it as an application which means it's downloading the
 entire website instead of just the data from the database... Anyone
 have any idea what to check?

Can you explain what you mean by downloading it as an application?...


-- 
Some people have a gift link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



[PHP] Another question about functions...

2008-01-29 Thread Jason Pruim

HI everyone,

I think I'm getting closer to understanding functions, but I'm  
blanking on how to fix a problem that I have... I am attempting to  
export a database to excel, which was working before converting the  
code into a function.


What's happening is, I have the code set and it downloads the file  
into excel, but it doesn't have the database fields in it, rather a  
copy of the entire webpage which it trys to put into excel. Below is  
the code that I am using in my function to export the records:


?PHP
function excelexportfunc($select, $sortOrder, $exportdate) {

$export = mysql_query($select);
$fields = mysql_num_fields($export);

for ($i = 0; $i  $fields; $i++) {
$header .= mysql_field_name($export, $i) . \t;
}

while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) or ($value == )) {
$value = \t;
}
else
{
$value = str_replace('', '', $value);
$value = '' . $value . '' . \t;
}   
$line .= $value;
}
$data .= trim($line). \n;
}
$data = str_replace(\r, , $data);

if ($data ==) {
$data =\n(0) Records Found!\n;
}

header(Content-type: application/vnd.ms-excel);
		header(Content-Disposition: attachment; filename=Export.. 
$exportdate..xls);

header(Pragma: no-cache);
header(Expires: 0);



print $header\n$data;

}

?

I am calling the function like so: excelexportfunc($select,  
$sortOrder, $exportdate);


the $select is specified in an IF statement on the calling page like so:

if($exportoption ==all){
$sortOrder= $_SESSION['order'];
$search = ;
$select = SELECT * FROM .$table. order by .$sortOrder.;

}else{

$sortOrder = $_SESSION['order'];
$search = $_SESSION['search'];
		$select = SELECT * FROM .$table. WHERE FName like '%.$search.%'  
or LName like '%.$search.%' or Add1 like '%.$search.%' or Add2  
like '%.$search.%' or City like '%.$search.%' or State like '%. 
$search.%' or Zip like '%.$search.%' or XCode like '%.$search.%'  
order by .$sortOrder.;

}

If anyone has any ideas I would love to hear about them. Hopefully  
it's just a simple . in the wrong place! :)



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




Re: [PHP] Another question about functions...

2008-01-29 Thread Nathan Nobbe
On Jan 29, 2008 11:07 AM, Jason Pruim [EMAIL PROTECTED] wrote:

 What's happening is, I have the code set and it downloads the file
 into excel, but it doesn't have the database fields in it, rather a
 copy of the entire webpage which it trys to put into excel.


this sounds to me like you may not be linking to the code that generates
the excel spreadsheet properly.  this is just a hunch, but to test it, you
might try pointing your browser directly at the script that generates the
excel spreadsheet, rather than navigating to it via a link you have on your
current page.
as far as the data not showing up in the output, try experimenting by
omitting the header() calls and just dump out the result set of the query
to ensure the data is actually getting populated in your function.

-nathan


Re: [PHP] Another question about functions...

2008-01-29 Thread Jason Pruim


On Jan 29, 2008, at 11:48 AM, Nathan Nobbe wrote:


On Jan 29, 2008 11:07 AM, Jason Pruim [EMAIL PROTECTED] wrote:
What's happening is, I have the code set and it downloads the file
into excel, but it doesn't have the database fields in it, rather a
copy of the entire webpage which it trys to put into excel.

this sounds to me like you may not be linking to the code that  
generates
the excel spreadsheet properly.  this is just a hunch, but to test  
it, you
might try pointing your browser directly at the script that  
generates the
excel spreadsheet, rather than navigating to it via a link you have  
on your

current page.
as far as the data not showing up in the output, try experimenting by
omitting the header() calls and just dump out the result set of the  
query

to ensure the data is actually getting populated in your function.

-nathan


Well, I commented out the header lines and just printed the data to  
the browser, and it fills it all in perfectly. So I think you are  
right about not calling it right... I'll do some more checking on  
that, back to the $salt farms I go! :)




--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




Re: [PHP] Another question about functions...

2008-01-29 Thread Nathan Nobbe
On Jan 29, 2008 3:53 PM, Jason Pruim [EMAIL PROTECTED] wrote:

 I did as you suggested, and I think I found the reason... I included info
 for the doctype, and some files that are on all my pages... Once I comment
 out those lines it works just fine...
 I'm assuming that that is expected behavior?


where did you include this information?
i didnt see it in the original code you posted.
and, btw. im no expert on setting mime types for excel :)

-nathan


Re: [PHP] Another question about functions...

2008-01-29 Thread Nathan Nobbe
On Jan 29, 2008 2:39 PM, Jason Pruim [EMAIL PROTECTED] wrote:

 Okay, so I checked everything I can think of, and it's still
 downloading it as an application which means it's downloading the
 entire website instead of just the data from the database... Anyone
 have any idea what to check?


im guessing youre trying to hit the invocation of excelexportfunc(), as
it sits in your existing script.  create a simple test script that does
nothing
else but invoke the excelexportfunc() function.  you can pass variables to
it from the url, or hardcode them if you like; id probly hardcode them at
first.

?php
include('excelexportfunc.php'); // -- set accordingly

$select = ''; // -- set me
$sortOrder = '' -- set me
$exportdate = '' -- set me

excelexportfunc($select, $sortOrder, $exportdate);
?

that *should* get you the results youre looking for.  from there you need to
determine why the method isnt working in the context of your existing
script.

-nathan


Re: [PHP] Another question about functions...

2008-01-29 Thread Jason Pruim


On Jan 29, 2008, at 11:58 AM, Jason Pruim wrote:



On Jan 29, 2008, at 11:48 AM, Nathan Nobbe wrote:


On Jan 29, 2008 11:07 AM, Jason Pruim [EMAIL PROTECTED] wrote:
What's happening is, I have the code set and it downloads the file
into excel, but it doesn't have the database fields in it, rather a
copy of the entire webpage which it trys to put into excel.

this sounds to me like you may not be linking to the code that  
generates
the excel spreadsheet properly.  this is just a hunch, but to test  
it, you
might try pointing your browser directly at the script that  
generates the
excel spreadsheet, rather than navigating to it via a link you have  
on your

current page.
as far as the data not showing up in the output, try experimenting by
omitting the header() calls and just dump out the result set of the  
query

to ensure the data is actually getting populated in your function.

-nathan


Well, I commented out the header lines and just printed the data to  
the browser, and it fills it all in perfectly. So I think you are  
right about not calling it right... I'll do some more checking on  
that, back to the $salt farms I go! :)



Okay, so I checked everything I can think of, and it's still  
downloading it as an application which means it's downloading the  
entire website instead of just the data from the database... Anyone  
have any idea what to check?



--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]

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



Re: [PHP] Another question about functions...

2008-01-29 Thread Jason Pruim


On Jan 29, 2008, at 2:46 PM, Nathan Nobbe wrote:


On Jan 29, 2008 2:39 PM, Jason Pruim [EMAIL PROTECTED] wrote:
Okay, so I checked everything I can think of, and it's still
downloading it as an application which means it's downloading the
entire website instead of just the data from the database... Anyone
have any idea what to check?

im guessing youre trying to hit the invocation of excelexportfunc(),  
as
it sits in your existing script.  create a simple test script that  
does nothing
else but invoke the excelexportfunc() function.  you can pass  
variables to
it from the url, or hardcode them if you like; id probly hardcode  
them at first.


?php
include('excelexportfunc.php'); // -- set accordingly

$select = ''; // -- set me
$sortOrder = '' -- set me
$exportdate = '' -- set me

excelexportfunc($select, $sortOrder, $exportdate);
?

that *should* get you the results youre looking for.  from there you  
need to
determine why the method isnt working in the context of your  
existing script.


-nathan




Hey Nathan,

I did as you suggested, and I think I found the reason... I included  
info for the doctype, and some files that are on all my pages... Once  
I comment out those lines it works just fine...


I'm assuming that that is expected behavior?


--

Jason Pruim
Raoset Inc.
Technology Manager
MQC Specialist
3251 132nd ave
Holland, MI, 49424
www.raoset.com
[EMAIL PROTECTED]




Re: [PHP] Another question about functions...

2008-01-29 Thread Chris



What's happening is, I have the code set and it downloads the file into 
excel, but it doesn't have the database fields in it, rather a copy of 
the entire webpage which it trys to put into excel. Below is the code 
that I am using in my function to export the records:


?PHP
function excelexportfunc($select, $sortOrder, $exportdate) {


echo $select . br/\n;

if you run that through your db manually do you get an error?


$export = mysql_query($select);


var_dump($export);


$fields = mysql_num_fields($export);


// initialize the header line to be an empty string.
$header = '';


for ($i = 0; $i  $fields; $i++) {
$header .= mysql_field_name($export, $i) . \t;
}


You will need a trim here otherwise you'll have an extra empty column 
(extra \t in there):


$header = trim($header);


while($row = mysql_fetch_row($export)) {
$line = '';
foreach($row as $value) {
if ((!isset($value)) or ($value == )) {
$value = \t;
}
else
{
$value = str_replace('', '', $value);
$value = '' . $value . '' . \t;
}   
$line .= $value;

}
$data .= trim($line). \n;
}
$data = str_replace(\r, , $data);
   
if ($data ==) {

$data =\n(0) Records Found!\n;
}
   
header(Content-type: application/vnd.ms-excel);
header(Content-Disposition: attachment; 
filename=Export..$exportdate..xls);

header(Pragma: no-cache);
header(Expires: 0);
   
   
   
print $header\n$data;


Once you've printed out the report, you should probably exit so nothing 
else is processed from the script.



}

?

I am calling the function like so: excelexportfunc($select, $sortOrder, 
$exportdate);


the $select is specified in an IF statement on the calling page like so:

if($exportoption ==all){
$sortOrder= $_SESSION['order'];
$search = ;
$select = SELECT * FROM .$table. order by .$sortOrder.;

}else{

$sortOrder = $_SESSION['order'];
$search = $_SESSION['search'];
$select = SELECT * FROM .$table. WHERE FName like 
'%.$search.%' or LName like '%.$search.%' or Add1 like 
'%.$search.%' or Add2 like '%.$search.%' or City like 
'%.$search.%' or State like '%.$search.%' or Zip like 
'%.$search.%' or XCode like '%.$search.%' order by .$sortOrder.;

}


$sortOrder is now part of $select you don't need to pass it to the 
function unless you actually use it in that function (which from your 
copy/paste isn't the case).



So your function can just be:

function excelexportfunc($select, $exportdate) {

and remove the $sortOrder from the calling lines:

excelexportfunc($select, $exportdate);

--
Postgresql  php tutorials
http://www.designmagick.com/

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



[PHP] Another question

2002-10-29 Thread Trasca Ion-Catalin
If I have a page with frames, how can I get the title of the frameset to be
the title of the main frame? I want this title to change every time the
visitor change the page.
Any help?

--
Trasca Ion-Catalin



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




[PHP] Another question - not exactly what i was looking for

2002-01-15 Thread Phil Schwarzmann

Yo, thanks for all your help.  But it isn't exactly what im looking for.

Let's say you had a database with the following four columns...

-LastName
-FirstName
-Age
-Weight

...and you wanted a page that would allow a user to search for one or
more of these fields within the database.

It would be easy if the user could only pick just one of the fields. 
But let's say that want to search only lastname and firstname, or maybe
all four, or maybe just one.  How could this be done?

If I have code that looks like this...

$query = select * from table where lastname='$lastname' and
firstname='$firstname' and age='$age' and weight='$weight';

$result  = mysql_query ($query);
$num_results = mysql_num_rows($result);

...the $num_results is ALWAYS zero unless I typed in all four fields.  

Any help?

Thanks!



Re: [PHP] Another question - not exactly what i was looking for

2002-01-15 Thread mike cullerton

how 'bout something like

$query = 'select * from table_name where ';
$and = '';
if ($lastname != '') {
 $query .= lastname = $lastname;
 $and = ' and ';
}
if ($firstname != '') {
 $query .= $comma.firstname = $firstname;
 $and = ' and ';
}

and so on

on 1/15/02 1:53 PM, Phil Schwarzmann at [EMAIL PROTECTED] wrote:

 Yo, thanks for all your help.  But it isn't exactly what im looking for.
 
 Let's say you had a database with the following four columns...
 
 -LastName
 -FirstName
 -Age
 -Weight
 
 ...and you wanted a page that would allow a user to search for one or
 more of these fields within the database.
 
 It would be easy if the user could only pick just one of the fields.
 But let's say that want to search only lastname and firstname, or maybe
 all four, or maybe just one.  How could this be done?
 
 If I have code that looks like this...
 
 $query = select * from table where lastname='$lastname' and
 firstname='$firstname' and age='$age' and weight='$weight';
 
 $result  = mysql_query ($query);
 $num_results = mysql_num_rows($result);
 
 ...the $num_results is ALWAYS zero unless I typed in all four fields.
 
 Any help?
 
 Thanks!
 


 -- mike cullerton   michaelc at cullerton dot com



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Another question - not exactly what i was looking for

2002-01-15 Thread R'twick Niceorgaw

construct your query like
$query = select * from table where ;
lastname='$lastname' and
 firstname='$firstname' and age='$age' and weight='$weight';

if (isset($lastname) and $lastname !=) then
$query.= lastname=$lastname ;
if (isset($firstname) and $firstname !=) then
$query.= and firstname=$firstname ;
and so on...

You may need to do some more checking like if there already been a field
selected earlier  if so then add AND  before the current field else don't
add the AND .
Hope that helps.

- Original Message -
From: Phil Schwarzmann [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Tuesday, January 15, 2002 3:53 PM
Subject: [PHP] Another question - not exactly what i was looking for


 Yo, thanks for all your help.  But it isn't exactly what im looking for.

 Let's say you had a database with the following four columns...

 -LastName
 -FirstName
 -Age
 -Weight

 ...and you wanted a page that would allow a user to search for one or
 more of these fields within the database.

 It would be easy if the user could only pick just one of the fields.
 But let's say that want to search only lastname and firstname, or maybe
 all four, or maybe just one.  How could this be done?

 If I have code that looks like this...

 $query = select * from table where lastname='$lastname' and
 firstname='$firstname' and age='$age' and weight='$weight';

 $result  = mysql_query ($query);
 $num_results = mysql_num_rows($result);

 ...the $num_results is ALWAYS zero unless I typed in all four fields.

 Any help?

 Thanks!



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Another question - not exactly what i was looking for

2002-01-15 Thread Christopher William Wesley

$where_conditions = array();
if( !empty( $lastname ) ){
$where_conditions[] = lastname like '%${lastname}%';
}
if( !empty( $firstname ) ){
$where_conditions[] = firstname like '%${firstname}%';
}
if( !empty( $age ) ){
$where_conditions[] = age = ${age};
}
if( !empty( $weight ) ){
$where_conditions[] = weight = ${lastname};
}

$where_clause = ;
$num_conditions = sizeof( $where_conditions );
if( $num_conditions  0 ){
$where_clause = where ;
for( $c = 0; $c  $num_conditions; $c++ ){
$where_clause .= $where_conditions[$c];
if( $c  $num_conditions - 1 ){
$where_clause .=   ;
}
}
}

$query = select * from table ${where_clause};

...

that should be flexible enough for you to add new
fields to check, by only having to add column = $value
values to the $where_conditions array.

g.luck,
~Chris   /\
 \ / September 11, 2001
  X  We Are All New Yorkers
 / \ rm -rf /bin/laden

On Tue, 15 Jan 2002, Phil Schwarzmann wrote:

 Yo, thanks for all your help.  But it isn't exactly what im looking for.

 Let's say you had a database with the following four columns...

 -LastName
 -FirstName
 -Age
 -Weight

 ...and you wanted a page that would allow a user to search for one or
 more of these fields within the database.

 It would be easy if the user could only pick just one of the fields.
 But let's say that want to search only lastname and firstname, or maybe
 all four, or maybe just one.  How could this be done?

 If I have code that looks like this...

 $query = select * from table where lastname='$lastname' and
 firstname='$firstname' and age='$age' and weight='$weight';

 $result  = mysql_query ($query);
 $num_results = mysql_num_rows($result);

 ...the $num_results is ALWAYS zero unless I typed in all four fields.

 Any help?

 Thanks!





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Another question

2001-08-24 Thread Dan McCullough

Okay I have stripped all header and bogus crap out of this file.
Now I am left with formatting and breaking the data up.
How can I do that?

Here is the script that gets me a clean file and print out.
These a piece thats missing up that is a command line script that parses the file for 
this
information.

?
$fcontents =  file(/tmp/mail_file.tmp, r);
$file_size = filesize (/tmp/mail_file.tmp);
echo bSize of this file is/b -  . $file_size . brbr;
while (list ($line_num, $line) = each ($fcontents)) {
//name, address, city, state, zip, email, optin end of line
//can you remove the field name
echo $linebr;
}
clearstatcache (void)
?

Here is my output:

State:: CA 
Name:: Alan T. Lim 
Address:: 3494 Yuba Avenue 
City:: San Jose 
e-mail: [EMAIL PROTECTED] 
Zip:: 95117 
State:: Colorado 
Name:: Paul Wu 
Address:: 2313 Hampshire Road 
City:: Fort Collins 
e-mail: [EMAIL PROTECTED] 
Zip:: 80526 
State:: Kentucky 
Name:: Janis Ross 
Address:: 2033 Damson Drive 
City:: Villa Hills 
e-mail: [EMAIL PROTECTED] 
Zip:: 41017

Here is the desired result, this also involves reordering information:

Alan T. Lim 3494 Yuba Avenue San Jose CA 95117 [EMAIL PROTECTED] yes
Paul Wu  2313 Hampshire Road Fort Collins Colorado 80526 [EMAIL PROTECTED] yes
Janis Ross 2033 Damson Drive Villa Hills Kentucky 41017 [EMAIL PROTECTED] yes

any help would be appreciated

thanks

dan

=
Dan McCullough
---
Theres no such thing as a problem unless the servers are on fire!
h: 603.444.9808
w: McCullough Family
w: At Work

__
Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger
http://phonecard.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] another question

2001-07-27 Thread Eduardo Kokubo

Does anybody knows how to redirect a page to new window with all the vars from the old 
one? Can I leave a message in the old window?

Thanks in advance.



Re: [PHP] another question

2001-07-27 Thread Daniel Rezny

Hello Eduardo,

Friday, July 27, 2001, 1:48:01 PM, you wrote:

EK Does anybody knows how to redirect a page to new window with all the vars from the 
old one? Can I leave a message in the old window?

EK Thanks in advance.

Use a javascript window.open() function with link with all values.

-- 
Best regards,
 Danielmailto:[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Another question about using shmop!

2001-02-28 Thread Christian Reiniger

On Wednesday 28 February 2001 00:15, you wrote:
  Does it provide a faster performance, if I use these rather than
  store things in mysql DB, I know this might be stupid, but I have to
  make sure this.

 I belive shared memory is *much* faster than MySQL.

Well, I'd say it depends. For only a bit of simple data it's fine. But 
for more the optimizations of a database (indices etc) may make the db 
faster (remember most of the DB will be in RAM as well).
And a database is just *much* simpler and safer to use.

 Shared memory is not for the faint of heart.

 I can't think of any more, but that's mostly because I consider shared
 memory "too tricky for me" and have never played with it...

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

CPU not found. retry, abort, ignore?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Another question about using shmop!

2001-02-27 Thread Richard Lynch

 I read about the php manual, I find that, shmop function can let me use
 to store information directly on a shared segment memory.

 However, I have some question about these!

 Does it provide a faster performance, if I use these rather than store
 things in mysql DB, I know this might be stupid, but I have to make sure
 this.

I belive shared memory is *much* faster than MySQL.

But there's nothing to "save" your data if the machine crashes, and all
sorts of tricky stuff you'll need to figure out on your own about shared
memory.

Shared memory is not for the faint of heart.

 And, can I shared the segment ( the data stored inside ) with different
 user session.
 Would you show me how.

Not only *can* you share it with different user sessions, you have no choice
about it.

The whole point of shared memory is that *EVERY* process on the machine is
using the same memory.

So, if you stuff "Hello World" into shared memory location 42, *every*
script, every program, every everything on that computer has "Hello World"
in shared memory location 42.  Period.

 Lastly, is there any further information about using this? the manual
 only take a little bit!!

There's bound to be a HowTo somewhere, but you will really need to be
careful.  Things you need to think about:

What if *two* people run this script at exactly the same time?
How do I know my script isn't tromping on other program's usage of shared
memory?

I can't think of any more, but that's mostly because I consider shared
memory "too tricky for me" and have never played with it...

--
Visit the Zend Store at http://www.zend.com/store/
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Another question about using shmop!

2001-02-26 Thread Zenith

I read about the php manual, I find that, shmop function can let me use
to store information directly on a shared segment memory.

However, I have some question about these!

Does it provide a faster performance, if I use these rather than store
things in mysql DB, I know this might be stupid, but I have to make sure
this.

And, can I shared the segment ( the data stored inside ) with different
user session.
Would you show me how.

Lastly, is there any further information about using this? the manual
only take a little bit!!

Thanks
Zenith


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]