Juan Morales
Juan Morales

Reputation: 1

Problems inner join in zend 1.12

I try to do a join in the following way but I can not, that I'm wrong? use zend 1.12

SELECT al.nombre, ar.nombre FROM `album` AS al
INNER JOIN artista AS ar ON al.artista_id = ar.id


$select = $this->select()
         ->from(array('al' => 'album'),
                array('id', 'nombre'))
         ->join(array('ar' => 'artista'),
                'al.artista_id = ar.id');
    $rows = $this->fetchAll($select);


    return $rows;

Upvotes: 0

Views: 137

Answers (2)

php-dev
php-dev

Reputation: 7156

Just set the integrity check flag

$select = $this->select()
     ->setIntegrityCheck(false)
     ->from(array('al' => 'album'),
            array('id', 'nombre'))
     ->join(array('ar' => 'artista'),
            'al.artista_id = ar.id');
$rows = $this->fetchAll($select);


return $rows;

Hope it helps

Upvotes: 2

volkinc
volkinc

Reputation: 2128

the problem was, you didn't use right object

$select = $this->select()
         ->from(array('al' => 'album'),
                array('id', 'nombre'))
         ->join(array('ar' => 'artista'),
                'al.artista_id = ar.id');

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


    return $rows;

Upvotes: 0

Related Questions