I need to implement the custom search function that will search data from another database so where I write the code as we do in CI MVC ?
The short answer is you won't be able to. ExpressionEngine is built in CodeIgnitor, not on top of so to speak.
While you have access total the CI Libs, helpers and modules, expressionengine impliments a complete templating solution which is designed to remove the need to understand MVC.
What you can do, (advanced extension topics herein!) Is write MVC within modules and plug-ins, to a fashion. You can also extend EE itself, if you spy into the EE system directory you'll see MVC starting to com through. You'll be able to load these MVC components using the EE loader too. One example is I like to replace the EE Mail class with my own implimentation.
Now for the completely off the hook, gone too far method. Take a look at the index.php in the root of the site, at the bottom you'll see run_ee() function call. This is what starts up the whole EE parsing system. in the system folder you'll see a similar index.php with a call to fire up the admin pages. In theory, you could keep the EE system and admin panel but impliment your own custom front end system, you could base this off CI MVC and all that.