Bonjour,


La table cto_postestypes et la table cto_fonctions sont liées

Code du model CtoPostestype.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
 
<?php
 
class CtoPostestype extends AppModel {
 
 
	var $name = 'CtoPostestype';
 
	var $displayField = 'liblong';
 
	var $virtualFields = array(
		'libdouble' => 'CONCAT(CtoPostestype.code, " - ", CtoPostestype.liblong)'
	);
 
	var $order = array('CtoPostestype.code' => 'asc');	
 
 
/**
 * Validation rules
 *
 */
	var $validate = array(
		'id' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),		
		'code' => array(
			'isUNique' => array(
				'rule' => array('isUNique'),
				'message' => 'Unique et non vide',
				'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'ouvert' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Non vide (0 ou 1)',
				'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'cto_fonction_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'Champ obligatoire',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		)
 
	);
 
 
/**
 * belongsTo associations
 *
 */
 
 
	var $belongsTo = array(
		'CtoFonction' => array(
			'className' => 'CtoFonction',
			'foreignKey' => 'cto_fonction_id',
			'conditions' => '',
			'fields' => '',
			'order' => ''
		)
 
	);
 
 
/**
 * hasMany associations
 *
 */
	var $hasMany = array(
 
 
'Poste' => array(
			'className' => 'Poste',
			'foreignKey' => 'cto_postestype_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
		);
/**
 * getListeDeroulantePostestypes
 *
 */
	function getListeDeroulantePostestypes() {
 
		$data = $this->find('list', array(	'fields'=>'libdouble',
											'order'=>'libdouble ASC')); 
		return $data;
	}
 
 
 
}
Code du model CtoFonction.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
 
<?php
 
class CtoFonction extends AppModel {
 
 
	var $name = 'CtoFonction';
 
 
	var $displayField = 'liblong';
 
 
	var $virtualFields = array(
		'libdouble' => 'CONCAT(CtoFonction.code, " - ", CtoFonction.liblong)'
	);
 
 
	var $order = array('CtoFonction.code' => 'asc');	
 
	var $validate = array(
		'id' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				//'message' => 'Your custom message here',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'code' => array(
			'isUNique' => array(
				'rule' => array('isUNique'),
				'message' => 'Unique et non vide',
				'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'ouvert' => array(
			'notempty' => array(
				'rule' => array('notempty'),
				'message' => 'Non vide (0 ou 1)',
				'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
		'cto_domaine_id' => array(
			'numeric' => array(
				'rule' => array('numeric'),
				'message' => 'Champ obligatoire',
				//'allowEmpty' => false,
				//'required' => false,
				//'last' => false, // Stop validation after this rule
				//'on' => 'create', // Limit validation to 'create' or 'update' operations
			),
		),
	);
 
 
 
/**
 * hasMany associations
 *
 */
	var $hasMany = array(
		'CtoPostestype' => array(
			'className' => 'CtoPostestype',
			'foreignKey' => 'cto_fonction_id',
			'dependent' => false,
			'conditions' => '',
			'fields' => '',
			'order' => '',
			'limit' => '',
			'offset' => '',
			'exclusive' => '',
			'finderQuery' => '',
			'counterQuery' => ''
		)
	);
 
 
/**
 * getListeDeroulanteFonctions
 *
 */
	function getListeDeroulanteFonctions ($cto_domaine_id = null) {
		$conditions = array();
		if ($cto_domaine_id) {
			$conditions = array('CtoFonction.cto_domaine_id' => $cto_domaine_id);
		}		
		$data = $this->find('list', array(	'conditions' => $conditions,
											'fields'=>'libdouble',
											'order'=>'libdouble ASC'));
		return $data;
	}
 
 
 
 
 
}
Dans mon controller si je mets le code suivant j'ai le message d'erreur "Notice (8): Undefined property: AppModel::$CtoFonction"
Malgré le
Code : Sélectionner tout - Visualiser dans une fenêtre à part
	var $uses=array('CtoPostestype','CtoFonction');
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
function index() {
 
 
$liste=$this->CtoPostestype->CtoFonction->find('all');	
 
				debug($liste);
				exit();
}

Avez vous une idée ? Merci pour vos réponses.
Pascale