To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > PHP Help > Code Critique

Code Critique Having someone critique your code is always a great way to hone the skills. Stop in and post your code to see what your peers may have done differently.

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-10-2003, 01:51 AM   #1
Tristan Wells
Member
 
Join Date: Oct 2003
Location: Louisiana
Posts: 38
MySQL database wrapper

Hey. I just finished writing my database wrapper and I need comments on it.
Thanks.

http://php.neohaven.com/nbsource/mysql.phps
__________________
The girls at school call me nerdalicious.
Tristan Wells is offline   Reply With Quote
Old 11-10-2003, 07:57 AM   #2
drawmack
Computers can do that?
 
drawmack's Avatar
 
Join Date: Apr 2003
Location: Pocono Mtns PA
Posts: 3,268
you don't comment your variables, you should so I know what they're for.

you have a variable that's only for postgre but you don't allow for postgre to be used in the class

in connect and select you don't error trap the actual command, what if it fails?
drawmack is offline   Reply With Quote
Old 11-10-2003, 09:17 AM   #3
Tristan Wells
Member
 
Join Date: Oct 2003
Location: Louisiana
Posts: 38
Connect and select check if connections are possible and if they arent it exits.
PHP Code:
<?p
if(!@mysql_pconnect($this->obj['host'],$this->obj['user'],
         
$this->obj['pass']))
          {
            
$this->error();
            exit;
          }
?>
__________________
The girls at school call me nerdalicious.
Tristan Wells is offline   Reply With Quote
Old 11-10-2003, 09:46 AM   #4
HalfaBee
Not very lazy.
 
Join Date: Jun 2003
Location: Sydney, Australia
Posts: 1,851
You need a function to return all the rows as an array.

Halfabee
__________________
The lazy man always finds the best way!
Q: Who invented the auto-pilot?
A: The lazy pilot!
HalfaBee is offline   Reply With Quote
Old 11-10-2003, 06:57 PM   #5
drawmack
Computers can do that?
 
drawmack's Avatar
 
Join Date: Apr 2003
Location: Pocono Mtns PA
Posts: 3,268
Quote:
Originally posted by Tristan Wells
Connect and select check if connections are possible and if they arent it exits.
what if in that microsecond between the execution of the if statment and the execution of the real statment something happens that makes the database no longer available? I know it's a long shot but it's a shot.
drawmack is offline   Reply With Quote
Old 11-10-2003, 07:03 PM   #6
Tristan Wells
Member
 
Join Date: Oct 2003
Location: Louisiana
Posts: 38
Quote:
Originally posted by HalfaBee
You need a function to return all the rows as an array.

Halfabee
Line 87-92.
PHP Code:
//+---------------------------------+\\
//+Fetch arrays from the database
//+---------------------------------+\\
   
function fetch($res)
    {
      return
mysql_fetch_array($res) or die($this->error());
    }
__________________
The girls at school call me nerdalicious.
Tristan Wells is offline   Reply With Quote
Old 11-10-2003, 07:06 PM   #7
HalfaBee
Not very lazy.
 
Join Date: Jun 2003
Location: Sydney, Australia
Posts: 1,851
This only returns 1 row.
I meant all the rows.

Halfabee
__________________
The lazy man always finds the best way!
Q: Who invented the auto-pilot?
A: The lazy pilot!
HalfaBee is offline   Reply With Quote
Old 11-10-2003, 07:27 PM   #8
Tristan Wells
Member
 
Join Date: Oct 2003
Location: Louisiana
Posts: 38
Quote:
Originally posted by HalfaBee
This only returns 1 row.
I meant all the rows.

Halfabee
Oh I see what you mean. I thought about it back when Nuke-Board was in the plannin stages but decided it wasn't needed because im a while() whore.
__________________
The girls at school call me nerdalicious.
Tristan Wells is offline   Reply With Quote
Old 11-17-2003, 01:04 PM   #9
Shrike
Not Yet Involved
 
Shrike's Avatar
 
Join Date: Oct 2003
Location: The Eighth, Sursamen
Posts: 2,254
I have a similar class written just for mysql, I have

mysql_put() method
mysql_get_hash() method
mysql_get_hashlist() method
mysql_get_tabledescription() method

also I always echo mysql_error() in each method for debugging
Shrike is offline   Reply With Quote
Old 12-02-2003, 06:06 PM   #10
perrio
Member
 
Join Date: Dec 2003
Location: tampa
Posts: 30
Comments

I'd like to know how you'll instantiate the obj object.

If i had to guess I'd say like this.

$newob = New obj("filename of class definition");

//then then refer to the functions associated with that class
like

$newob ->connect();

etc...

?


But how do you get values into the newly declared object?
Mind clarifying what a wrapper is?
perrio is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 09:12 AM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.