foreach ($paramarray as $key => $value) { if ('orderby' == $key) { $orderby = $value; continue; } // only accept those keys that correspond to // table columns if ( array_key_exists ( $key, Comment::default_fields() ) ) { $where[] = "$key = ?"; $params[] = $value; } }