You are here: Re: Is this a good idea? « PHP Programming Language « IT news, forums, messages
Re: Is this a good idea?

Posted by sam.s.kong on 09/26/71 11:37

> I found a code that suits my intention.
>
> <?php
>
> class mysql_array
> {
>
> public function __construct ( $s_host , $s_user , $s_pass ,
> $s_db )
> {
> $this -> r_conn = mysql_connect ( $s_host , $s_user ,
> $s_pass ) or die ( mysql_error ( ) ) ;
> mysql_select_db ( $s_db ) ;
> }
>
> private function array_make ( $s_sql , $i_type )
> {
> $r_rs = mysql_query ( $s_sql , $this -> r_conn ) or die (
> mysql_error ( ) ) ;
> while ( $a_col = mysql_fetch_array ( $r_rs , $i_type ) )
> {
> $a_rs [ ] = $a_col ;
> }
> mysql_free_result ( $r_rs ) ;
> return ( $a_rs ) ;
> }
>
> public function array_logic ( $s_sql )
> {
> $a_rs = $this -> array_make ( $s_sql , MYSQL_NUM ) ;
> return ( $a_rs ) ;
> }
>
> public function array_assoc ( $s_sql )
> {
> $a_rs = $this -> array_make ( $s_sql , MYSQL_ASSOC ) ;
> return ( $a_rs ) ;
> }
>
> public function array_both ( $s_sql )
> {
> $a_rs = $this -> array_make ( $s_sql , MYSQL_BOTH ) ;
> return ( $a_rs ) ;
> }
>
> }
>
> $o_mysql = new mysql_array ( 'localhost' , 'user' , 'pass' , 'db' )
> ;
> $s_sql = "SHOW TABLES" ;
> $a_rs = $o_mysql -> array_assoc ( $s_sql ) ;
>
> echo '<pre>' ;
> print_r ( $a_rs ) ;
>
> ?>
>
> It's from http://us2.php.net/manual/en/ref.mysql.php .

I forgot to ask "Do you think the above code is ok in terms of
performance and memory usage?"

Sam

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация