Bin will be removed on June 1, 2014 in favor of http://gist.github.com. Please save all your pastes before then. So long, and thanks for all the fish!×
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//Temp model in import function
        $RemoteHeader = new AppModel(array(
                    'table' => 'SOP10100',
                    'ds' => 'external',
                    'name' => 'RemoteHeader',
//                    'alias' => 'InvoiceHeader',
                    'primaryKey' => 'SOPNUMBE',
                    'hasMany' => array(
                        'InvoiceDetail' => array(
                            'foreignKey' => 'SOPNUMBE',
                            'counterCache' => false
                    ))));
//fetch
        $data = $RemoteHeader->find('all', array(
            'fields' => array(
                'SOPNUMBE',
                'CUSTNAME',
                'DUEDATE',
                'DOCDATE',
                'DOCAMNT',
                'SUBTOTAL')));
 
//fetch result with no ALIAS set
    (int) 0 => array(
        'RemoteHeader' => array(
            'SOPNUMBE' => 'SVC0202088           ',
            'CUSTNAME' => 'LOUISIANA ENERGY CONSULTANTS, INC.                               ',
            'DUEDATE' => '2012-05-17 00:00:00',
            'DOCDATE' => '2012-04-17 00:00:00',
            'DOCAMNT' => '.00000',
            'SUBTOTAL' => '.00000'
        )
    )
//fetch result with ALIAS set
    (int) 0 => array(
        'InvoiceHeader' => array(
            'SOPNUMBE' => 'SVC0202088           ',
            'CUSTNAME' => 'LOUISIANA ENERGY CONSULTANTS, INC.                               ',
            'DUEDATE' => '2012-05-17 00:00:00',
            'DOCDATE' => '2012-04-17 00:00:00',
            'DOCAMNT' => '.00000',
            'SUBTOTAL' => '.00000'
        )
   
//Load local model in save function
        if(!isset($this->InvoiceHeader)){
            $this->loadModel('InvoiceHeader');
        }
 
//Problem
If I remove the alias in the temp model, loadModel loads correct model, but $data has incorrect element name -- RemoteHeader. If I add the alias, the reverse is true.