Esempio n. 1
0
 public static function findByHash($hash = '')
 {
     if (!isset($hash) || $hash === '') {
         return null;
     }
     $hashValue = db_sql_encode($hash);
     $query = "SELECT * FROM blogTripAttribute " . "WHERE hash={$hashValue} " . "ORDER BY updated DESC " . "LIMIT 1";
     $result = mysql_query($query);
     if (!$result) {
         // Error executing the query
         print $query . "<br/>";
         print " --> error: " . mysql_error() . "<br/>\n";
         return null;
     }
     if (mysql_num_rows($result) <= 0) {
         // Trip does not exist
         return null;
     }
     // Create a Trip object with a special trip ID '-' to bypass the
     // checks on empty ID. The ID value will be overwritten by the
     // value coming back from the database anyway.
     $trip = new TripAttribute('-', '-');
     if ($trip->loadFromResult($result)) {
         return $trip;
     }
     return null;
 }