I am migrating from ZF1 Zend_db to ZF2. I have problems connecting to the db and making a simple query. Appreciate if someone can guide me along. Below is my code.
This is how i connect to db
use Zend\Db\Adapter\Adapter;
$dbo = new Zend\Db\Adapter\Adapter(array(
'driver' => 'pdo_mysql',
'database' => DB_PREFIX.DB_NAME,
'username' => DB_USER,
'password' => DB_PW
));
Zend_Registry::set('db', $dbo);
This isan example how i use it.
$this->dbo = Zend_Registry::get('db');
function createData($message,$tags,$userid,$imgsrc){
$data= array(
'message' => $message,
'tags' => $tags,
'imgsrc' => $imgsrc,
'createdtimestamp'=>new Zend_Db_Expr('NOW()'),
'userid' => $userid);
$this->dbo->insert('mydata', $data);
return $this->dbo->lastInsertId();
}
I have an error. That is $dbo does not have select(),insert() methods etc. I could did it in ZF1 zend db.
Example of error message i received:
Fatal error: Call to undefined method Zend\Db\Adapter\Adapter::select() in