0

How could I set up custom DB adapter (I will use simple DBSimple) and then use it inside of my model? I don't want to extend my model with Zend_Db_Table, it seems pretty useless for me at the moment.

Sorry for question, but I'm real noob in ZF.

Thank you

2 Answers 2

4

If you really want to have a custom adapter in the ZF sense, you have to extend their Zend_Db_Adapter_Abstract class and implement all methods within for use with DBSimple. If you do this, you can use the adapter with the entire Zend_Db package and you would also set it up like any other ZF adapter.

If you don't care about compatibility with the Zend_Db package, you just use DBSimple like you always do. If you want to set it up during your app's bootstrap and you are using Zend_Application, either create a custom Resource Plugin or add an _initDb method in your Zend_Application_Bootstrap_Bootstrap. See the chapter on Zend_Application in the reference guide for more details on how to do this.

Sign up to request clarification or add additional context in comments.

1 Comment

I don't want to use Zend_Db, so I will use Bootstrap. Thank you very much!
0

try this, creat a model class

function __construct(){
    $this->select = new Zend_Db_Select(Zend_Db_Table::getDefaultAdapter());
}
//creat a function to use the db connection created in the __construct function
public function getDatabaseRow(){ 

    $select= $this->select
            ->from('TableName')
             ->where ('columnName =?','$option')

     $query = $select->query(); 
     $rows = $query->fetchAll();

    return $rows;
}

}

u can now iterate thru the rows;

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.