You seem to think that ZF2 and ZF1 are (and should be) class-compatible. The problem is, they're not - at least in regards to Zend\Db\Adapter
. That one in ZF2 is much more concise: while it has query
method, its main responsibility is abstracting the DB connection itself.
I suppose what you're looking for is located in Zend\Db\Sql area. Assuming you have your DB connection in $dbo
, you can create an Sql object based on it:
use Zend\Db\Sql as Sql;
$sql = new Sql\Sql($dbo);
... then create another object (of Zend\Db\Sql\Insert
class):
$insert = $sql->insert('mydata');
$insert->values([
'message' => $message,
'tags' => $tags,
'imgsrc' => $imgsrc,
'createdtimestamp'=>new Sql\Expression('NOW()'),
'userid' => $userid
]);
... then use this object in query:
$insertString = $sql->getSqlStringForSqlObject($insert);
$results = $dbo->query($insertString, Adapter::QUERY_MODE_EXECUTE);