I want to pass data fetch from database to phtml file located at following location.
I tried placing code mymodule/Block/IndexController.php and other location using
To get data.
$var = Mage::registry('name-of-registry-key');
Where in module folder I need to place this code to be able to access from phtml file.
Also Is it good practice to get database connection phtml file to perform work using $connection =
They work but they are not good practice.
To get data in tempalte, you should set data to the block which rendering this template or create a public function in that block. If the template does not have a custom block, you can use a helper.
To perform db operation, you should use model or resource model to utilize the full power of ORM.