How do I make a function available to several CodeIgniter methods?
===

- CodeIgniter 2.1.2

I have a class that contains two methods, for the purpose of this questions `showone` and `view`. The latter returns all items of a small database and can also perform a search. The other one is for permalinks like `domain.com/showone/firstname-lastname`

    <?php
    class Pages extends CI_Controller {

    public function view($page)
        {
        //this includes a mysql search
        }

    public function showone($slug)
        {
        //abbreviated version:
        $query = "SELECT * FROM mytable WHERE slug = '" . $slug . "'";
        $result = $this->db->query($query);
        if ($result->num_rows() == 0)
            {
            //here is where I'd like to use the same search that I used in showall
            }
        else
            {
            //show the one item
            }
        }
    
    } //class
    ?>

So if a user decides to directly enter a URL that doesn't return anything from the database, I would like to direct him to search results instead of showing a 404.

So how do I set up a `function searchdatabase($query)` to be used by both `showone` and `view`?