CSV Export foreig table


I am exporting to CVS like this, but I do get an error accesing the foreign table ‘sexo’, please some help.


public function export()


    $this->layout = 'ajax';

    $filename = "Exportacion.csv";

    $csv_file = fopen('php://output', 'w');

    header('Content-type: application/csv');

    header('Content-Disposition: attachment; filename="'.$filename.'"');

    $results = $this->Empleados->Find('all');

    $header_row = array("identificacion", 














    foreach($results as $result)


        $row = array(

















You haven’t contained the sexo association when you find your empleados.

$results = $this->Empleados->Find(‘all’)

Thanks. :smiley:

I’m building my first from-scratch database in SQL Server and wanted to generate some mock data to import into one of my tables. I can import the CSV as a new table but if I try to add it to an existing table it fails due to an issue with the foreign key. The generated data for the foreign key column was within the range of numbers used in the primary key of the referenced table.

I got this done on my own,…