0

I am using below code to fetch data from db.

$w = Mage::getSingleton('core/resource')->getConnection('core_read'); 
$table = Mage::getSingleton('core/resource')->getTableName('mymodule/mymodule');

$result = $w->select()
    ->from($table)
    ->where('t_store in(0,?)', Mage::app()->getStore()->getStoreId());

$row = $w->fetchAll($result);

It is giving me an array of array something like below

Array
(
    [t_id] => 4
    [t_store] => 0
    [t_name] => name1
    [t_text] => text1
)
Array
(
    [t_id] => 6
    [t_store] => 0
    [t_name] => name2
    [t_text] => text2
)

But I wanted to have only t_text in my result set something like below

Array
(
    [t_text] => text1
)
Array
(
    [t_text] => text2
)

How can I modify my code or query to have above result set? Any help will be appreciated.

2
  • try $w->select('t_text'). Jul 24, 2014 at 6:15
  • @programmer_rkt Tried, it is not working. Jul 24, 2014 at 6:19

2 Answers 2

2

Try it with:

$result = $w->select()
    ->reset(Zend_Db_Select::COLUMNS)
    ->columns('t_text')
    ->from($table)
    ->where('t_store in(0,?)', Mage::app()->getStore()->getStoreId());
3
  • Sorry, it is not working. Jul 24, 2014 at 6:37
  • @AnshuMishra. I've edited the answer. Give it a try now.
    – Marius
    Jul 24, 2014 at 6:39
  • Still not working. Jul 24, 2014 at 6:42
1

Below code worked for me.

$result = $w->select()
    ->from($table, 't_text')
    ->where('t_store in(0,?)', Mage::app()->getStore()->getStoreId());

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.