php5 coding class objects best practices

php5 coding class objects best practices

am 16.11.2006 11:22:46 von Chris Barnes

------=_Part_71230_5698634.1163672566120
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

hi people,
i havent used thi slist for quite a while.

anyway. Im trying to write an application which relies heavily on mysql. so
i have made a class object which has all the functions to make using mysql
very easy for me.

but the problem im faced with now is, i have a bunch of other classes, which
have a dependency to be able to read or write to mysql at some point.

i dont want to have to write and maintain seperate mysql classes to extend
other other classes.

is it alright to, for example, point to one class from within another?

e.g.

$user = new User();

$user->mysql = new MySql();

and then call functions in MySql() from within User() by;

$this->mysql->fetch_result_into_array();

im new to PHP5 so im not aware of all its new and awesome OO features.

does anyone have any advise?

------=_Part_71230_5698634.1163672566120--

Re: php5 coding class objects best practices

am 17.11.2006 00:57:36 von Chris

Chris Barnes wrote:
> hi people,
> i havent used thi slist for quite a while.
>
> anyway. Im trying to write an application which relies heavily on mysql. so
> i have made a class object which has all the functions to make using mysql
> very easy for me.
>
> but the problem im faced with now is, i have a bunch of other classes,
> which
> have a dependency to be able to read or write to mysql at some point.
>
> i dont want to have to write and maintain seperate mysql classes to extend
> other other classes.
>
> is it alright to, for example, point to one class from within another?
>
> e.g.
>
> $user = new User();
>
> $user->mysql = new MySql();
>
> and then call functions in MySql() from within User() by;
>
> $this->mysql->fetch_result_into_array();
>
> im new to PHP5 so im not aware of all its new and awesome OO features.

Yes, that will work fine.

It also works in php4, it's not a php5 specific feature.

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

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