Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-24 Thread Robert Cummings
On Mon, 2007-12-24 at 12:13 -0500, tedd wrote: > At 4:18 PM +0200 12/19/07, Sancar Saran wrote: > > > that said, avoid globals like the plague - sometimes you may come up with > >> a situation where using a global is really necessary - such situations > >> should be the exception rather than the

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-24 Thread Sancar Saran
Hello Tedd, Here my opinoins First of all, I ask this question to is there any technical dead end for using $GLOBALS directly. It seems not. And I believe other arguments was closely connected to coding style. I'm self learner, I learn evrything about computers, programming (that means PHP)

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-24 Thread tedd
At 4:18 PM +0200 12/19/07, Sancar Saran wrote: > that said, avoid globals like the plague - sometimes you may come up with a situation where using a global is really necessary - such situations should be the exception rather than the rule, often if your thinking of using a global there is an

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-21 Thread Sancar Saran
example code // current code //--- Set DB $GLOBALS['db'] = NewADOConnection($GLOBALS['c']['db']['type'].'://'. $GLOBALS['c']['db']['user'].':'.$GLOBALS['c']['db']['pass'].'@'.$GLOBALS['c'] ['db']['host'].'/'.$GLOBALS['c']['db']['name']); $ADODB_FETCH_MODE = ADODB_FETCH_NUM; // Fastest Get Method

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-21 Thread Nathan Nobbe
On Dec 21, 2007 2:46 PM, Robert Cummings <[EMAIL PROTECTED]> wrote: > On Fri, 2007-12-21 at 12:35 -0600, Philip Thompson wrote: > > On Dec 20, 2007, at 11:24 AM, Sancar Saran wrote: > > > > > Hello All, > > > > > > Thanks for joining the conversation. It seems there where no real > > > technical >

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-21 Thread Robert Cummings
On Fri, 2007-12-21 at 12:35 -0600, Philip Thompson wrote: > On Dec 20, 2007, at 11:24 AM, Sancar Saran wrote: > > > Hello All, > > > > Thanks for joining the conversation. It seems there where no real > > technical > > dead end for using $GLOBALS directly. > > Using $GLOBALS directly very simila

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-21 Thread Philip Thompson
On Dec 20, 2007, at 11:24 AM, Sancar Saran wrote: Hello All, Thanks for joining the conversation. It seems there where no real technical dead end for using $GLOBALS directly. Using $GLOBALS directly very similar to coding standarts. It just up to you. Also I try explain my enviroment a l

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-21 Thread Stut
Richard Lynch wrote: On Wed, December 19, 2007 11:22 am, Stut wrote: well, if you have a long and complex function declaration which begins with global $whatever, and then all over the function $whatever is used, some dozens of lines later when looking for something in the code you might not hav

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-20 Thread Richard Lynch
On Wed, December 19, 2007 11:22 am, Stut wrote: >> well, if you have a long and complex function declaration which >> begins >> with global $whatever, and then all over the function $whatever is >> used, >> some dozens of lines later when looking for something in the code >> you >> might not have a

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-20 Thread Sancar Saran
Hello All, Thanks for joining the conversation. It seems there where no real technical dead end for using $GLOBALS directly. Using $GLOBALS directly very similar to coding standarts. It just up to you. Also I try explain my enviroment a liddle bit. First of all my function declarationgs gonna

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Stut
Zoltán Németh wrote: 2007. 12. 19, szerda keltezéssel 10.25-kor Richard Lynch ezt írta: On Wed, December 19, 2007 10:14 am, Stut wrote: Richard Lynch wrote: On Wed, December 19, 2007 4:13 am, Sancar Saran wrote: I want know to you opinions about using $GLOBALS directly. like $GLOBALS['mySt

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Zoltán Németh
2007. 12. 19, szerda keltezéssel 10.25-kor Richard Lynch ezt írta: > On Wed, December 19, 2007 10:14 am, Stut wrote: > > Richard Lynch wrote: > >> On Wed, December 19, 2007 4:13 am, Sancar Saran wrote: > >>> I want know to you opinions about using $GLOBALS directly. > >>> > >>> like > >>> > >>> $G

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Richard Lynch
On Wed, December 19, 2007 10:14 am, Stut wrote: > Richard Lynch wrote: >> On Wed, December 19, 2007 4:13 am, Sancar Saran wrote: >>> I want know to you opinions about using $GLOBALS directly. >>> >>> like >>> >>> $GLOBALS['myString'] = 'test'; >>> $GLOBALS['myArray']['this'] = 'this'; >>> $GLOBALS

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Richard Lynch
On Wed, December 19, 2007 8:18 am, Sancar Saran wrote: > Thanks for response, I'm using this aproach maybe more than one year. > I did > not get any problems. >> >> there is no real difference between 'global $foo' and >> $GLOBALS['foo'], >> and the second is probably more maintainance friendly (as

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Stut
Richard Lynch wrote: On Wed, December 19, 2007 4:13 am, Sancar Saran wrote: I want know to you opinions about using $GLOBALS directly. like $GLOBALS['myString'] = 'test'; $GLOBALS['myArray']['this'] = 'this'; $GLOBALS['myArray']['that'] = 'that'; $GLOBALS['myClassObj] = new SomeClass; Don't

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Jochem Maas
js schreef: > Hi Jochem, > > Sorry, I missed "static". > So, getDB() would works like singleton, right? yes - and it was just pseudo code off the top of my head, also there are 2 slightly different ways to attack this - one is to return an object that contains all the DB functionality (and stores

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Richard Lynch
On Wed, December 19, 2007 8:14 am, js wrote: > That wouldn't work well when you have to update multiple tables in a > transaction. > I think it's more maintainable to use GLOBALS than passing around dbh > to classes/functions. I also just use a 'global' for my db connection, for small to medium we

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Richard Lynch
On Wed, December 19, 2007 4:13 am, Sancar Saran wrote: > I want know to you opinions about using $GLOBALS directly. > > like > > $GLOBALS['myString'] = 'test'; > $GLOBALS['myArray']['this'] = 'this'; > $GLOBALS['myArray']['that'] = 'that'; > $GLOBALS['myClassObj] = new SomeClass; Don't. You are

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Jochem Maas
Richard Heyes schreef: >>> I always store database handler in $GLOBALS. >>> I think that's the best place to save request-level-global. >>> I wonder where other people save that kind of data. >> >> how about a static variable inside a function or a static member of a >> class. >> >> e.g. >> >> func

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Robin Vickery
On 19/12/2007, js <[EMAIL PROTECTED]> wrote: > Hi Jochem, > > Sorry, I missed "static". > So, getDB() would works like singleton, right? > I agree that's better method to manage dbh. The technique is called memoization (http://en.wikipedia.org/wiki/Memoization). -robin -- PHP General Mailing Li

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread js
Hi Jochem, Sorry, I missed "static". So, getDB() would works like singleton, right? I agree that's better method to manage dbh. On Dec 19, 2007 11:27 PM, Jochem Maas <[EMAIL PROTECTED]> wrote: > js schreef: > > That wouldn't work well when you have to update multiple tables in a > > transaction.

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Richard Heyes
I always store database handler in $GLOBALS. I think that's the best place to save request-level-global. I wonder where other people save that kind of data. how about a static variable inside a function or a static member of a class. e.g. function getDB($args) { static $conn = array();

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Jochem Maas
js schreef: > That wouldn't work well when you have to update multiple tables in a > transaction. > I think it's more maintainable to use GLOBALS than passing around dbh > to classes/functions. getDB() is a function that returns a database connection wrapper object not a handle to a connection (th

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Sancar Saran
Hello Jochem, Thanks for response, I'm using this aproach maybe more than one year. I did not get any problems. > > there is no real difference between 'global $foo' and $GLOBALS['foo'], > and the second is probably more maintainance friendly (as Rob pionted out) Yes you are right writing globa

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread js
That wouldn't work well when you have to update multiple tables in a transaction. I think it's more maintainable to use GLOBALS than passing around dbh to classes/functions. On Dec 19, 2007 11:07 PM, Jochem Maas <[EMAIL PROTECTED]> wrote: > please reply to the list ... > > js schreef: > > I always

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Jochem Maas
please reply to the list ... js schreef: > I always store database handler in $GLOBALS. > I think that's the best place to save request-level-global. > I wonder where other people save that kind of data. how about a static variable inside a function or a static member of a class. e.g. function

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Jochem Maas
Sancar Saran schreef: > Hello list. > > I want know to you opinions about using $GLOBALS directly. > > like > > $GLOBALS['myString'] = 'test'; > $GLOBALS['myArray']['this'] = 'this'; > $GLOBALS['myArray']['that'] = 'that'; > $GLOBALS['myClassObj] = new SomeClass; there is no real difference be

Re: [PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Robert Cummings
On Wed, 2007-12-19 at 12:13 +0200, Sancar Saran wrote: > Hello list. > > I want know to you opinions about using $GLOBALS directly. > > like > > $GLOBALS['myString'] = 'test'; > $GLOBALS['myArray']['this'] = 'this'; > $GLOBALS['myArray']['that'] = 'that'; > $GLOBALS['myClassObj] = new SomeClass

[PHP] Opinion about the using $GLOBALS directly

2007-12-19 Thread Sancar Saran
Hello list. I want know to you opinions about using $GLOBALS directly. like $GLOBALS['myString'] = 'test'; $GLOBALS['myArray']['this'] = 'this'; $GLOBALS['myArray']['that'] = 'that'; $GLOBALS['myClassObj] = new SomeClass; Regards Sancar -- PHP General Mailing List (http://www.php.net/) To u