RE: 'Code Snippets' you couldn't live without

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

 



I agree that shorthand is probably bad for, BUT... Greg is absolutely
correct.  The gist of the post was "What do YOU use frequently".  His
examples were good enough to illustrate the idea.

For me, I have a handful of includes that are in most/a lot of my
scripts.   I'm not going to paste them here because they're rather
lengthy (which is why I have them as includes).

They include the following:

1. ADOdb + a dbconnect include.  I like using ADOdb because for a while
I was using MySQL, Oracle AND SQL Server (now mostly just SQL Server,
but some Oracle as well).  Even though I don't really use ADOdb's full
power, I like being able to write standard SQL and use a few prep
variables and connect to whereever I need to.   I have my connection
strings defined in my 'dbconnect' and just say $database = "Oracle".
Pass the database, the sql string and I also send the report name (I use
the "APP=$reportname" in my connection string so I can identify one of
my scripts' processes looking at the process list on the database
server).   The results come back in an array that I use the same set of
commands to parse when it's done.    My "dbconnect" also logs db errors
to a text file or alternately logs ALL sql queries (if I set a
$verbosity variable).

2. dateconvert - I have a handful of functions to convert from one date
format to another.  This is helpful in so many ways.  Nuff said

3. metrics - Logging script usage by snagging the NT username, user's IP
address, time, date, script run, etc



Those are the big ones.


This kind of topic is kind of useful for the PHP development team as
well because if there are functions that people keep writing themselves,
then they may be good candidates to make into standard functions.   I'm
always amazed at how much PHP does already and I'm guessing a lot of
those functions came out of someone saying "Hey..  We all use this type
of function CONSTANTLY..  Can it be built into PHP's core instead of us
having to INCLUDE it all the time?"

-TG

> -----Original Message-----
> From: Greg Donald [mailto:destiney@xxxxxxxxx] 
> Sent: Wednesday, November 03, 2004 2:56 PM
> To: php-general@xxxxxxxxxxxxx
> Subject: Re:  'Code Snippets' you couldn't live without
> 
> 
> On Wed, 03 Nov 2004 20:22:14 +0100, Klaus Reimer <k@xxxxxxxx> wrote:
> > This may be ok for private projects but otherwise I don't 
> think it's a
> > good idea to create "shorthand" functions.
> 
> Murray wasn't asking for your opinions on _his_ code, he was asking
> what code _you_ had that you couldn't live without, code that makes
> your life easier when reused from project to project.
> 
> Criticism comes easy when you have nothing to contribute otherwise.
> 
> 
> -- 
> Greg Donald
> Zend Certified Engineer
> http://gdconsultants.com/
> http://destiney.com/
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 

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



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

  Powered by Linux