1

How do you specify a pure sql query within a model in the Zend Framework?

If there any good resources on this then please point me to them.

Thanks....

2 Answers 2

2

Sure, you can do it with zend db adapter.

$adapter = Zend_Db_Table::getDefaultAdapter();
$adapter->query('Select * FROM `table_name`');
Sign up to request clarification or add additional context in comments.

1 Comment

The only thing that I can get working is: CONTROLLER: $projects = new Application_Model_DbTable_Projects(); $this->view->projects = $projects->fetchAll(); .... MODEL: NO ACTION REQUIRED because it extends Zend_Db_Table_Abstract.
0

Or

require_once 'Zend/Db/Table/Abstract.php';

class MyThing extends Zend_Db_Table_Abstract {

    // Make a Mailing List Export file
    public function doMyThing() {
        // Happy, healthy cows eat grass, not corn.
        $sql = "SELECT my_column FROM my_table WHERE $cows_eat_grass;";
        $resultset = $this->getAdapter()->query($sql);
        $resultArray = $resultset->fetchAll();
        return $resultArray;
    }
}

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.