{"action":"created","issue":{"url":"https://api.github.com/repos/zendframework/zf2/issues/6457","labels_url":"https://api.github.com/repos/zendframework/zf2/issues/6457/labels{/name}","comments_url":"https://api.github.com/repos/zendframework/zf2/issues/6457/comments","events_url":"https://api.github.com/repos/zendframework/zf2/issues/6457/events","html_url":"https://github.com/zendframework/zf2/issues/6457","id":37783714,"number":6457,"title":"zf2 paginator with join","user":{"login":"matatla","id":8158070,"avatar_url":"https://avatars.githubusercontent.com/u/8158070?v=3","gravatar_id":"","url":"https://api.github.com/users/matatla","html_url":"https://github.com/matatla","followers_url":"https://api.github.com/users/matatla/followers","following_url":"https://api.github.com/users/matatla/following{/other_user}","gists_url":"https://api.github.com/users/matatla/gists{/gist_id}","starred_url":"https://api.github.com/users/matatla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matatla/subscriptions","organizations_url":"https://api.github.com/users/matatla/orgs","repos_url":"https://api.github.com/users/matatla/repos","events_url":"https://api.github.com/users/matatla/events{/privacy}","received_events_url":"https://api.github.com/users/matatla/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-07-14T12:56:54Z","updated_at":"2015-11-06T17:24:22Z","closed_at":"2015-11-06T17:24:22Z","body":"I have a problem when I use pagination with join. I've this function:\r\n\r\n\t\tif ($paginated) {       \r\n\t\t\t$select = new \\Zend\\Db\\Sql\\Select ();\r\n\t\t\t$select->from ( 'cliente' );\r\n\t\t\t$select->columns ( array ('*'), false );\r\n\t\t\t$select->join ( 'privato', \"cliente.idCliente = privato.idCliente\", array ('*'), 'left' );\r\n\t\t\t$select->join ( 'azienda', \"cliente.idCliente = azienda.idCliente\", array ('*'), 'left' );\r\n\r\n\t\t\t$resultSetPrototype = new ResultSet ();\r\n\t\t\t$resultSetPrototype->setArrayObjectPrototype ( new Cliente () );\r\n\t\t\t$paginatorAdapter = new DbSelect ( \r\n\t\t\t$select, \r\n\t\t\t$this->tableGateway->getAdapter ()); \r\n\t\t\t$resultSetPrototype );\r\n\t\t\t//$paginatorAdapter = $this->tableGateway->selectWith ( $select );\r\n\t\t\t$paginator = new Paginator ( $paginatorAdapter );\r\n\t\t\treturn $paginator;\r\n\t\t}\r\n\r\n\t\t$select = new \\Zend\\Db\\Sql\\Select ();\r\n\t\t$select->from ( 'cliente' );\r\n\t\t$select->columns ( array ('*') );\r\n\t\t$select->join ( 'privato', \"cliente.idCliente = privato.idCliente\", array ('*'), 'left' );\r\n\t\t$select->join ( 'azienda', \"cliente.idCliente = azienda.idCliente\", array ('*'), 'left' );\r\n\r\n\t\t$resultSet = $this->tableGateway->selectWith ( $select );\r\n\t\treturn $resultSet;\r\n\r\nthe code outside the if statement works correctly, the internal code no. Gives me this message:\r\n\r\n            Statement could not be executed (42S21 - 1060 - Duplicate column name 'idClient\r\n\r\nWhat's the problem?"},"comment":{"url":"https://api.github.com/repos/zendframework/zf2/issues/comments/154478277","html_url":"https://github.com/zendframework/zf2/issues/6457#issuecomment-154478277","issue_url":"https://api.github.com/repos/zendframework/zf2/issues/6457","id":154478277,"user":{"login":"adamlundrigan","id":527329,"avatar_url":"https://avatars.githubusercontent.com/u/527329?v=3","gravatar_id":"","url":"https://api.github.com/users/adamlundrigan","html_url":"https://github.com/adamlundrigan","followers_url":"https://api.github.com/users/adamlundrigan/followers","following_url":"https://api.github.com/users/adamlundrigan/following{/other_user}","gists_url":"https://api.github.com/users/adamlundrigan/gists{/gist_id}","starred_url":"https://api.github.com/users/adamlundrigan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamlundrigan/subscriptions","organizations_url":"https://api.github.com/users/adamlundrigan/orgs","repos_url":"https://api.github.com/users/adamlundrigan/repos","events_url":"https://api.github.com/users/adamlundrigan/events{/privacy}","received_events_url":"https://api.github.com/users/adamlundrigan/received_events","type":"User","site_admin":false},"created_at":"2015-11-06T17:24:22Z","updated_at":"2015-11-06T17:24:22Z","body":"I think it's this:\r\n\r\n```php\r\n$select->columns ( array ('*'), false );\r\n```\r\n\r\nWhich results in a SQL query like this:\r\n\r\n```sql\r\nSELECT *, \"privato\".*, \"azienda\".* FROM \"cliente\" LEFT JOIN \"privato\" ON \"cliente\".\"idCliente\" = \"privato\".\"idCliente\" LEFT JOIN \"azienda\" ON \"cliente\".\"idCliente\" = \"azienda\".\"idCliente\"\r\n```\r\n\r\nSo every column is being selected twice, once by the `*` and once by the `<table>.*`"}}