Select Query

Select Query:- It is used to get the records from the custom table.

Syntax:-

[php]
$read_connection = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’);
$query_data="select * from tablename";
$rowsArray = $read_connection->fetchAll($query_data); // return all rows
$rowArray = $read_connection->fetchRow($query_data); //return row
[/php]

Example:- Suppose, you have to get all records from the employee table.

[php]
$read_connection = Mage::getSingleton(‘core/resource’)->getConnection(‘core_read’);
$query_data="select * from employee";
$rowsArray = $read_connection->fetchAll($query_data); // return all rows
[/php]