NYCPHP Meetup

NYPHP.org

[nycphp-talk] confused by classes

Daniel Convissor danielc at analysisandsolutions.com
Sun May 2 23:10:49 EDT 2004


On Sat, May 01, 2004 at 06:50:33PM -0400, chris wrote:

First, your coding style needs improvement.  See 
http://pear.php.net/manual/en/standards.php

> class mailUser{
>         var $user;
> function mailUser ($user){
>     $dsn = 'mysql://username:pass@localhost/db';
>     $dbh = DB::connect($dsn);

Assign the return by reference in order to conserve memory, etc:
      $dbh =& DB::connect($dsn);

>     $user = $dbh->quote($user);

quote() is deprecated.  Use quoteSmart().


>     $this->user = $dbh->getAssoc("SELECT server, m_user, m_pass, pop, smtp, 
... snip ...

So, there can be multiple rows of data returned for a given user?  If it's
only one row, use getRow().

>        AND u.username LIKE $user");

Don't you mean "= $user" rather than "LIKE $user"?


> And then when a user is logged in (returns $user ) I go:
> $cur_user = new mailUser($user);

Again, do that with "=&" to assign by reference instead of assigning a 
copy.


> This gives me an object with an array of servers, each of those having an 
> array of parameters. But I guess what I really need, maybe, is a class that 
> returns 
> $this->server
> with a few methods (seperate queries?) to extract the parameters specific to 
> the currently active server?

It's not clear what you're looking for here.

--Dan

-- 
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
            data intensive web and database programming
                http://www.AnalysisAndSolutions.com/
 4015 7th Ave #4, Brooklyn NY 11232  v: 718-854-0335 f: 718-854-0409



More information about the talk mailing list