Skip to content

u/omerida

In this archive from May 2011 to Nov 2026

16
posts
477
comments
3
media
1.7k
score

Top posts

Top comments

  1. Stop using mysql_ functions, they're deprecated. Most developers use PDO or mysqli, each has its strengths.

  2. Use prepared statements to prevens SQL injection attacks. Both PDO and mysqli can do this.

  3. Document your methods using phpdoc standard, you can then generate documentation and your IDE will be more useful.

  4. If your DB calls error, and log the message in your error handler, does the rest of your method still execute? Seems if there's an issue in one query, the rest of the code shouldn't execute.

  5. I think returning an error code is frowned upon (-1, -2), seems this might be a case where throwing an exception (ExpiredPromoCodeException for example) would be better. At least, make the return codes class constants, so that calling code does:

$redeem = $this->RedeemPromotionalCode('12345', 'Freebie);

switch ($redeem) { case CouponClass::expiredCode: // handle expired code break; case CouponClass::invalidCode: // handle invalid code break; }

  1. Your method does a lot, consider breaking it up into smaller methods that each do one thing. One to test if the code is valid, another to test if its expired, another method to write the usage details.

  2. You should wrap all the writes to the database into a database transaction that you can rollback if any insert fails. http://php.net/manual/en/pdo.transactions.php

63 points

As others have said, the client doesn't need to be involved in your decision to use version control. Its a tool of the trade, and ideally you'd steer away from devs who don' t use version control

Now, if the issue is that they don't want to install git/svn/whatever so that you can deploy from VC, then that's their choice. You still have SSH to deploy via, right? Though, I suspect w/this client it's more likely FTP?

32 points

Subreddits

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.