/** * @return unknown * @param String $field * @param String $table * @param String $where * @param String $order * @param Integer $fetch * @desc Selects a record from the database in a number of ways */ function selrecord($field, $table, $where, $order, $fetch) { $row = ''; $sql = "SELECT {$field} FROM {$table}"; if ($where) { $sql .= " WHERE {$where}"; } if ($order) { $sql .= " ORDER BY {$order}"; } debug::message($sql . '<br><br>'); $result = mysql_query($sql) or die("Couldna select records - " . mysql_errno() . ": " . mysql_error()); if ($fetch == 1) { // return all rows as arrays, packaged up in an array $row = array(); for ($index = 0; $aresult = dbs::fetchrecord_mode($result, MYSQL_ASSOC); $index++) { $row[$index] = $aresult; } } elseif ($fetch == '2') { $row = dbs::fetchrecord_mode($result, MYSQL_NUM); } elseif ($fetch == '3') { // return all rows as values in an array // only works when a single value is being fetched $row = array(); for ($index = 0; $aresult = dbs::fetchrecord_mode($result, MYSQL_NUM); $index++) { $row[$index] = $aresult[0]; } } elseif ($fetch == '4') { $row = dbs::fetchrecord_mode($result, MYSQL_ASSOC); } else { $row = $result; } return $row; }