I have a table:
*CREATE TABLE IF NOT EXISTS `blogs_settings` (
`blog_id` int(11) NOT NULL AUTO_INCREMENT,
`owner_id` int(11) NOT NULL,
`title` varchar(
Give it a try:
namespace Object\Model;
use Zend\Db\TableGateway\AbstractTableGateway;
use Zend\Db\Sql\Select;
class BlogsSettingsTbl extends AbstractTableGateway {
public function __construct($adapter) {
$this->table = 'blogs_settings';
$this->adapter = $adapter;
$this->initialize();
}
public function fetchAll() {
$where = array(); // If have any criteria
$result = $this->select(function (Select $select) use ($where) {
$select->join('users', 'blogs_settings.owner_id = users.user_id', array('username'));
//echo $select->getSqlString(); // see the sql query
});
return $result;
}
}
Add to 'getServiceConfig()' in Module.php:
'Object\Model\BlogsSettingsTbl' => function($sm) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
$table = new BlogsSettingsTbl($dbAdapter); // <-- also add this to 'USE' at top
return $table;
},