private function sanitize_input($astring)
 {
     $astring = trim($astring);
     $astring = stripslashes($astring);
     $astring = htmlspecialchars($astring);
     $astring = parent::getDbConnection()->real_escape_string($astring);
     return $astring;
 }
 public function multiFieldChangeToArrayAssociative($aQuery)
 {
     $tempKeys = array();
     $tempValue = array();
     $fetchFields = array();
     // run SQL query using database connection
     if ($result = parent::getDbConnection()->query($aQuery)) {
         $fetchFields = $result->fetch_fields();
         foreach ($fetchFields as $val) {
             $tempKeys[] = $val->name;
         }
         /*
         echo "<br />";
         print_r($tempKeys);
         echo "<br />Count Keys before flip: ".count($tempKeys);
         */
         // flip the values to keys
         $tempKeys = array_flip($tempKeys);
         // strip values
         $tempKeys = array_keys($tempKeys);
         // Returns true or false, true if there is a row
         // Creates a numeric array for each value that was fetched from database
         while ($row = $result->fetch_array(MYSQLI_NUM)) {
             // Iterate through array and place in temporary array.
             foreach ($row as $key => &$field) {
                 $tempValue[$key] = $field;
             }
         }
         /*
         echo "<br />";
         print_r($tempValue);
         echo "<br />Count values before flip: ".count($tempValue);
         */
         // strip keys
         $tempValue = array_values($tempValue);
         //echo count($tempValue);
         if (count($tempValue) == 0) {
             return array("REQUEST_TICKET_NUMBER" => '');
         }
         // strip keys
         $tempValue = array_values($tempValue);
         // Double the keys to make the same number of elements in each array on next combine.
         //$tempKeys = array_combine( $tempKeys, $tempKeys);
         // combine
         $tempValue = array_combine($tempKeys, $tempValue);
         /* free result set <-- memory*/
         $result->free();
         // return the array
         return $tempValue;
     } else {
         echo "No results from database, check your sql statement.";
     }
 }
 public function updateFirstName($oldName, $newName)
 {
     $stmt = parent::getDbConnection()->prepare("UPDATE TB_TESTMATT SET FIRST_NAME = ? WHERE FIRST_NAME LIKE ? LIMIT 1");
     // added % to string for the wild card LIKE and sanitized the string
     $tempOne = $this->sanitizeStringForSQL('%' . $oldName . '%');
     $tempTwo = $this->sanitizeStringForSQL($newName);
     $stmt->bind_param('ss', $tempTwo, $tempOne);
     // Save to Database
     $stmt->execute();
 }
 private static function setDbConnection($host, $user, $password, $database)
 {
     self::$DATABASE_CONNECTION = new mysqli($host, $user, $password, $database);
 }