Optimize SQL Querys with static cachin' because we have to much querys with same Select Statements.

signwriter.module Line: 568 signwriter_load_profile

function signwriter_load_profile($p) {
	
  static $profiles;
  	
  $id = is_numeric($p) ? $p : (!empty($p->id) ? $p->id : 0);
  $name = is_string($p) ? $p : (!empty($p->name) ? $p->name : '');
  
  if ($id) {
  	
    if (is_array($profiles) && array_key_exists($p, $profiles) )
    {
  	  $profile = $profiles[$p];
    }else
    {
  	  $profile = db_fetch_object(db_query("SELECT * FROM {signwriter} WHERE id = %d", $id));
  	  $profiles[$p] = $profile;
    }
    return $profile;
  }
  else {
    return db_fetch_object(db_query("SELECT * FROM {signwriter} WHERE name = '%s'", $name));
  }
}