Permalink
Browse files

Added commenting to SQL class.

  • Loading branch information...
1 parent ccf03dd commit c7bb1d1b201e27e9f6999f98cdf9d7e325bffaf9 @b-turchyn committed Jul 6, 2011
Showing with 44 additions and 0 deletions.
  1. +44 −0 src/classes/sql.php
View
@@ -68,6 +68,13 @@ public function __destruct() {
mysqli_close($this);
}
+ /**
+ * Retrieves the number of first names of a particular gender in the database
+ *
+ * @param string $gender 'M' or 'F' (case-sensitive)
+ * @return integer >= 0 on success, false on failure
+ * @author Brian Turchyn
+ */
public function getFirstNameCount($gender) {
$result = false;
$stmt = null;
@@ -87,6 +94,12 @@ public function getFirstNameCount($gender) {
return $result;
}
+ /**
+ * Retrieves the number of last names in the database
+ *
+ * @return integer >= 0 on success, false on failure
+ * @author Brian Turchyn
+ */
public function getLastNameCount() {
$result = false;
$stmt = null;
@@ -105,6 +118,14 @@ public function getLastNameCount() {
return $result;
}
+ /**
+ * Retrieves a specific first name from the database
+ *
+ * @param char $gender Either 'M' or 'F' (case-sensitive)
+ * @param integer $index Optional specific index
+ * @return string on success, boolean false on failure
+ * @author Brian Turchyn
+ */
public function getFirstName($gender, $index = null) {
$result = false;
$stmt = null;
@@ -128,6 +149,13 @@ public function getFirstName($gender, $index = null) {
return $result;
}
+ /**
+ * Retrieves a specific last name from the database
+ *
+ * @param integer $index
+ * @return string on success, boolean false on failure
+ * @author Brian Turchyn
+ */
public function getLastName($index = null) {
$result = false;
$stmt = null;
@@ -151,10 +179,26 @@ public function getLastName($index = null) {
return $result;
}
+ /**
+ * Generates a full name, either a specific index or a random one
+ *
+ * @param char $gender Either 'M' or 'F' (case-sensitive)
+ * @param integer $first optional first name index
+ * @param integer $last optional last name index
+ * @return string on success, false on failure
+ * @author Brian Turchyn
+ */
public function getFullName($gender, $first = null, $last = null) {
return $this->getFirstName($gender, $first) . " " . $this->getLastName($last);
}
+ /**
+ * Prepares the query to populate the DB table prefixes
+ *
+ * @param string $query
+ * @return string query with the database prefix
+ * @author Brian Turchyn
+ */
private function preparePrefix($query) {
return preg_replace("/%s/", $this->prefix, $query);
}

0 comments on commit c7bb1d1

Please sign in to comment.