Bonjour,
voila, ca fait deux jours que je cherche a comprendre mon erreur, ce doit etre une petite erreur d'écriture, mais j'ai beau chercher, je ne l'a trouve pas...
Voici mon erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
Fatal error: Call to a member function getUserId() on a non-object in /ETOOLS/etools/Tools/COTSDB/COTSDB_1_1/site/test/class/User.php on line 52
Et voici mes classes User et Acquisition:
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
class Acquisition {
 
// ATTRIBUTES
        private $acquisition_id;
        private $purchase_manager;
	private $purchase_order;
 
// CONSTRUCTOR
        public function __construct() {
        }
 
// SETTERS
        public function setAcquisitionId($value)      	{ $this->acquisition_id = $value; }
        public function setPurchaseManager($p)		{ $purchase_manager = New User(); $purchase_manager->setFromUser($p); }
        public function setPurchaseOrder($value)	{ $this->purchase_order = $value; }
 
        public function set($acquisition_id, $purchase_manager, $purchase_order) {
        	$this->setAcquisitionId($acquisition_id);
        	$this->setPurchaseManager($purchase_manager);
        	$this->setPurchaseOrder($purchase_order);
        }
 
        public function setFromAcquisition($a) {
        	$this->setAcquisitionId($a->getAcquisitionId());
        	$this->setPurchaseManager($a->getPurchaseManager());
        	$this->setPurchaseOrder($a->getPurchaseOrder());
        }
 
// GETTERS
        public function getAcquisitionId()      	{ return $this->acquisition_id; }
        public function getPurchaseManager()		{ return $this->purchase_manager; }
        public function getPurchaseOrder()		{ return $this->purchase_order; }
 
        public function get(){
                return array(getAcquisitionId(), getPurchaseManager(), getPurchaseOrder());
        }
 
// DATABASE ACCESS
        public function getAcquisitionFromDb($db, $idAcquisition){
		$query = "SELECT * FROM `acquisition`
				WHERE `id_acquisition`=?";
		$myAcquisition = $db->prepare($query);
		$myAcquisition->execute(array($idAcquisition));
		$row = $myAcquisition->fetch(PDO::FETCH_OBJ);
 
		$myPurchaseManager = new User();
		$myPurchaseManager->getUserFromDb($db, $row->id_purchase_manager);
 
		$this->set($row->id_acquisition, $myPurchaseManager, $row->purchase_order);
        }
 
        public function addToDb(){
        }
 
        public function updateDb(){
        }
 
        public function deleteFromDb(){
        }
}
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
class User {
 
// ATTRIBUTES
        private $user_id;
        private $right;
	private $location;
	private $user_last_name;
	private $user_first_name;
	private $phone;
	private $email;
	private $department;
	private $login;
	private $password;
	private $last_login;
 
// CONSTRUCTOR
        public function __construct() {
        }
 
// SETTERS
        public function setUserId($value)      			{ $this->user_id = $value; }
 
        public function setRight($r)				{ $this->right = new Right(); $this->right->setFromRight($r); }
        public function setLocation($l)				{ $this->location = new Location(); $this->location->setFromLocation($l); }
 
        public function setUserLastName($value)      		{ $this->user_last_name = $value; }
	public function setUserFirstName($value)      		{ $this->user_first_name = $value; }
	public function setPhone($value)      			{ $this->phone = $value; }
	public function setEmail($value)      			{ $this->email = $value; }
	public function setDepartment($value)      		{ $this->department = $value; }
	public function setLogin($value)      			{ $this->login = $value; }
	public function setPassword($value)      		{ $this->password = $value; }
	public function setLastLogin($value)      		{ $this->last_login = $value; }
 
 
        public function set($user_id, $right, $location, $user_last_name, $user_first_name, $phone, $email, $department, $login, $password, $last_login) {
        	$this->setUserId($user_id);
        	$this->setRight($right);
		$this->setLocation($location);
		$this->setUserLastName($user_last_name);
		$this->setUserFirstName($user_first_name);
		$this->setPhone($phone);
		$this->setEmail($email);
		$this->setDepartment($department);
		$this->setLogin($login);
		$this->setPassword($password);
		$this->setLastLogin($last_login);
        }
 
        public function setFromUser($u) {
		$this->setUserId($u->getUserId());
        	$this->setRight($u->getRight());
		$this->setLocation($u->getLocation());
		$this->setUserLastName($u->getUserLastName());
		$this->setUserFirstName($u->getUserFirstName());
		$this->setPhone($u->getPhone());
		$this->setEmail($u->getEmail());
		$this->setDepartment($u->getDepartment());
		$this->setLogin($u->getLogin());
		$this->setPassword($u->getPassword());
		$this->setLastLogin($u->getLastLogin());
        }
 
// GETTERS
        public function getUserId()      			{ return $this->user_id; }
 
        public function getRight()				{ return $this->right; }
        public function getLocation()				{ return $this->location; }
 
        public function getUserLastName()      			{ return $this->user_last_name; }
	public function getUserFirstName()      		{ return $this->user_first_name; }
	public function getPhone()      			{ return $this->phone; }
	public function getEmail()      			{ return $this->email; }
	public function getDepartment()      			{ return $this->department; }
	public function getLogin()      			{ return $this->login; }
	public function getPassword()      			{ return $this->password; }
	public function getLastLogin()      			{ return $this->last_login; }
 
        public function get(){
                return array(getUserId(), getFromRight(), getFromLocation(), getUserLastName(), getUserFirstName(), getPhone(), 
				getEmail(), getDepartment(), getLogin(), getPassword(), getLastLogin());
        }
 
// DATABASE ACCESS
        public function getUserFromDb($db, $idUser){
		$query = "SELECT * FROM `user`
				WHERE `id_user`=?";
		$myUser = $db->prepare($query);
		$myUser->execute(array($idUser));
		$row = $myUser->fetch(PDO::FETCH_OBJ);
 
		$myRight = new Right();
		$myRight->getRightFromDb($db, $row->id_right);
		$myLocation = new Location();
		$myLocation->getLocationFromDb($db, $row->id_location);
 
		$this->set($row->id_user, $myRight, $myLocation, $row->user_last_name, $row->user_fist_name, $row->phone, 
				$row->email, $row->department, $row->login, $row->password, $row->last_login);
        }
 
        public function addToDb(){
 
        }
 
        public function updateDb(){
 
        }
 
        public function deleteFromDb(){
        }
}
Petite explication pour la compréhension:
Ma table Acquisition contient un champs purchase manager qui est en fait clé étrangere de la table User....

Commencant la programmation objet en PHP, merci aussi de me dire si mon code est pourri ou non ^^

Cordialement,
Arnoulp