IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Classes et variables externes [PHP 5.3]


Sujet :

Langage PHP

  1. #61
    Débutant Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Points : 170
    Points
    170
    Par défaut Class OOP vous avez dit facile ?
    Grunk,

    Pourrais-je avoir ton avis sur les bouts de code que je développe pour l'instant destiné à résoudre mon problème Supplier/Provider

    Ma classe Vendeur

    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
    <?php
    // =============================================================================================================================== //
    //                                 Class PROVIDER                                                                                  //
    // =============================================================================================================================== //
    class Seller
    {	private $container ;
     
    	function __construct($container)
    	{ 	$this->container = $container ;
    		print("Seller instanciated" .CRLF) ; 
    		$this->container->addSeller((string) "S1")  ;  
    	}
     
    	function __destruct() 
    	{ print("Request destroyed"    .CRLF) ;   }  
     
    	function addSelling()
    	{	$this->container->addSelling( array( microtime() , "Membre", "GU_Email" ) ) ;
    		$this->container->addSelling( array( microtime() , "Membre", "GU_Member") ) ;
    	}
     
    	function notify($event)
    	{}
     }
    ?>
    Ma classe "Acheteur"

    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
    <?php
    // =============================================================================================================================== //
    //                                 Class BUYER                                                                                  //
    // =============================================================================================================================== //
    class Buyer
    {	private $container ;
     
    	function __construct($container)
    	{ 	$this->container = $container ;
    		print("Buyer instanciated" .CRLF) ; 
    		$this->container->addBuyer((string) "B1") ;  
    	}
     
    	function __destruct() 
    	{ 	print("Buyer destroyed"    .CRLF) ;   }  
     
    	function addBuying()
    	{	$this->container->addBuying( array( microtime() , "Membre", "GU_Email") ) ;
    		$this->container->addBuying( array( microtime() , "Membre", "Membre"  ) ) ;  
    	}
     
    	function notify($event)
    	{}
    }
    ?>
    Et mon Container qui fera partie de mon Skelet:

    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
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    <?php
    define("CRLF" , "\n<br>") ;
    require_once $_SERVER['DOCUMENT_ROOT'] . "/class/seller.php";  
    require_once $_SERVER['DOCUMENT_ROOT'] . "/class/buyer.php";  
    
    /**
    * 	Class Container: will pas through "request" & "supply" to the corresponding class but is responsible of the matching events !
    *	=============================================================================================================================
    */
    class Container
    {	private $buyer  = array() ;
    	private $seller = array() ;
    
    	function __contruct()
    	{	$this->execute() ;  }
    	
    	function execute()
    	{	try {
    				
    			} catch (Exception $E) 
    				{	throw("SKELETON CONNECTION ERROR: " . $this->display_exception($E) . CRLF);
    				}
    	}
    	
    	function __destruct()
    	{}
    
    /**
    * 	add Seller
    *	------------
    * 	param obj: objname instanciated and having an "notify" property to be get in touch
    * ============================================================================================================================= 
    */
    	function addSeller( $obj )
    	{	print("AddSeller: " . $obj . CRLF) ;
    Ligne 35 ==>		$this->seller[] =  (string) $obj ;	
    	}
    	
    /**
    * 	remove Seller
    *	---------------
    */
    	function removeSeller($obj)
    	{	if ( in_array($this->seller , $obj) )
    			unset( $this->seller[$obj] ) ;   
    		else
    			return(false) ;
    	}
    	
    /**
    * 	count Seller
    *	--------------
    */
    	function countSeller($obj)
    	{	return( $this->seller ) ; }
    	
    /**
    * 	print Seller
    *	--------------
    */
    	function printSeller()
    	{	print("printseller" . CRLF) ; 
    		print_r($this->seller ) ;
    		
    		for ($i = 0 ; $i < count($this->seller) ; $i++)
    		{	print($i . " seller[". $this->seller[$i] . CRLF ) ;	}
    	}
    	 
    /**
    * 	print Sales
    *	-----------
    */
    	function printSales()
    	{	print("printseller" . CRLF) ; 
    		print_r($this->seller ) ;
    		
    		for ($i = 0 ; $i < count($this->seller) ; $i++)
    		{	print($i . " Stamp   [". $this->seller[$i][0]."] => 
    		                Class    [". $this->seller[$i][1]."] => 
    						Ressource[". $this->seller[$i][2]."]" . CRLF ) ;  
    		}
    	}
    	 
    /**
    * 	add Buyer
    *	------------
    * 	param obj: objname instanciated and having an "notify" property to be get in touch
    * ============================================================================================================================= 
    */
    	function addBuyer( $obj )
    	{	$this->buyer[] = $obj ; }
    	
    /**
    * 	remove Buyer
    *	---------------
    */
    	function removeBuyer($obj)
    	{	if ( in_array($this->buyer , $obj) )
    			unset( $this->buyer[$obj] ) ;   
    		else
    			return(false) ;
    	}
    	
    /**
    * 	count Buyer
    *	--------------
    */
    	function countBuyer($obj)
    	{	return( count($this->buyer) ) ; }
    	
    /**
    * 	print Buyer
    *	--------------
    */
    	function printBuyer()
    	{	print("printBuyer" . CRLF) ; 
    		print_r($this->buyer ) ;
    		
    		for ($i = 0 ; $i < count($this->buyer) ; $i++)
    		{	print($i . " seller[". $this->buyer[$i] . CRLF ) ;	}
    	}
    	 
    /**
    * 	print Sales
    *	-----------
    */
    	function printSelling()
    	{	print("printSelling" . CRLF) ; 
    		print_r($this->buyer ) ;
    		
    		for ($i = 0 ; $i < count($this->buyer) ; $i++)
    		{	print($i . " Stamp   [". $this->buyer[$i][0]."] => 
    		                Class    [". $this->buyer[$i][1]."] => 
    						Ressource[". $this->buyer[$i][2]."]" . CRLF ) ;  
    		}
    	}
    	 
    /**
    * 	display Exception
    *	-----------------
    */
       function display_exception($E)
       {	$T = $E->getTrace() ; 
    	//	======================================================================
    		print("MYsql error diagnostic" .  "<br>\n") ;
    		print("================" .  "<br>\n") ;
    		print("Message: " . $E->getMessage() . " - File: " . $E->getFile() . " - Line: " . $E->getLine() . "<br>\n") ;
    		print("<br>\n") ;
    		print("Trace: " . "<br>\n") ;
    		print("------ " . "<br>\n") ;
    		print( "   => File               : " . $T[0]["file"]     . "<br>\n") ;
    		print( "   => calling instruction: " . $T[0]["line"]     . "<br>\n") ;
     		print( "   => error class        : " . $T[0]["class"]    . "<br>\n") ;
    		print( "   => error function     : " . $T[0]["function"] . "<br>\n") ;
    	//	======================================================================
    		user_error("Catching[connect error in File: " . $T[0]["file"] . "] - line: [" . $T[0]["line"] . "]" , E_USER_ERROR) ;  
    	//	======================================================================
    	}
    }
    
    $container = new Container() ;
    $container->addBuyer (new Buyer ($container) ) ;
    $container->addSeller(new Seller($container) ) ;
    
    $container->printSeller() ;
    //$container->printBuyer() ;
    
    ?>
    L'idée de base était d'enregister moi vendeur V1, je vends X, ma méthode est M1 et ma propriété NOTIFY

    Idem pour les acheteurs.....

    Mais j'ai des soucis PHP, raison pour laquelle j'ai séparé (pour voir) l'enregistrement du vendeur et de ses articles à vendre (idem pour l'acheteur)

    Mais PHP râle:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    [18-Jun-2010 11:29:18] PHP Catchable fatal error:  Object of class Seller could not be converted to string in F:\WebSites\container\index.php on line 35
    Merci de tes remarques et sugqestions
    Esteban

  2. #62
    Membre expert
    Avatar de ThomasR
    Homme Profil pro
    Directeur technique
    Inscrit en
    Décembre 2007
    Messages
    2 230
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 2 230
    Points : 3 972
    Points
    3 972
    Par défaut
    Bonjour,

    Pourrais-tu créer un autre sujet à propos de ton nouveau problème car celui-ci est résolu ?

    Aussi, je ne comprend pas la finalité de tes classes Provider / Supplier etc.. des méthodes n'ont pas de paramètres là alors qu'elles le devraient (je pense à addSelling). Dans ton nouveau sujet, penses à bien détailler ton problème avec des explications concises et du code spécifique, c'est à dire pas toutes tes classes.

    À bientôt,

  3. #63
    Débutant Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Points : 170
    Points
    170
    Par défaut supplier/obserser
    Thomas...

    Mais depuis lors, cela a déjà bcp évolué....

    Dispatcher

    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
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
     
    <?php
    define("CRLF" , "\n<br>") ;
    require_once $_SERVER['DOCUMENT_ROOT'] . "/class/seller.php";  
    require_once $_SERVER['DOCUMENT_ROOT'] . "/class/buyer.php";  
     
    /**
    * 	Class Disparcher: will pas through "request" & "supply" to the corresponding class but is responsible of the matching events !
    *	=============================================================================================================================
    */
    class Disparcher
    {	private $buyer  = array() ; // Identify of buyer
    	private $seller = array() ; // Identify of seller
     
    	private $sales  = array() ; // What the seller is providing
    	private $buying = array() ;	// What the customer is waiting for
     
    	function __contruct()
    	{	$this->execute() ;  }
     
    	function execute($msg)
    	{	$time   = $msg[0] ;
    		$who    = $msg[1] ;
    		$method = $msg[2] ;
    		$item   = $msg[3] ;
    		try {	//	(array( microtime() , "addSeller" , "Membre" , "GU_email" )  )
    				//  (array( microtime() , "addBuying" , "Membre" , "GU_email" )  )
    				switch($who):
    					case "addSeller" :  $this->addSelling($time, $who, $method, $item) ;
    										break ;
     
    					case "addBuying"  :  $this->addBuying($time, $who, $method, $item) ;
    										break ;
     
    				endswitch ;
     
    				$this->searchMatching() ;
     
    			} catch (Exception $E) 
    				{	throw("Disparcher ERROR: " . $this->display_exception($E) . CRLF);
    				}
    	}
     
    	function __destruct()
    	{}
    /**
    * 	searchMatching
    *	--------------
    * 	param Search matching between salers and buyers
    * =================================================
    */
     
    	function searchMatching()
    	{	//
    		//	priority to Buyer.... Sales can stand by, they are just proposing services
    		//  To be delivered first are Interset between Sales AND Buying
    		//  Priority to Buying order by microtime
    		//  Asking the providing about the service he can provide
    		//  Receiving Results
    		//  Ack of that receivee
    		//  Tellind the Buyer that I have something for him
    		//  Sending him qhat he is asking for
    		//  Received Ack of good transmission
    		//  Remove Request from internam array !
    		//  ============================================================================
    		$providing = array_intersect($this->sales , $this->buying) ;
    		print_r($this->providing) ;
    	}
     
    /**
    * 	add Seller
    *	------------
    * 	param obj: objname instanciated and having an "notify" property to be get in touch
    * ============================================================================================================================= 
    */
    	function addSeller( $obj )
    	{	$this->seller[] =  $obj ;	}
     
    /**
    * 	add Good to be sell
    *	--------------------
    * 	param obj: objname instanciated and having an "notify" property to be get in touch
    * ============================================================================================================================= 
    */
    	function addSelling( $time, $who , $method, $item )
    	{	print(' ==>addSelling[' . $who . '] - [' . $method . '] - [' . $item  . ']' . CRLF) ;
    		$this->sales[] =  array( $time, $who, $method, $item )  ;	
    	}
     
    /**
    * 	remove Seller
    *	---------------
    */
    	function removeSeller($obj)
    	{	if ( in_array($this->seller , $obj) )
    			unset( $this->seller[$obj] ) ;   
    		else
    			return(false) ;
    	}
     
    /**
    * 	count Seller
    *	--------------
    */
    	function countSeller($obj)
    	{	return( $this->seller ) ; }
     
    /**
    * 	print Seller
    *	--------------
    */
    	function printSeller()
    	{	print("printseller" . CRLF) ; 
    		print_r($this->seller ) ;
     
    		for ($i = 0 ; $i < count($this->seller) ; $i++)
    		{	print($i . " seller[". $this->seller[$i] . CRLF ) ;	}
    	}
     
    /**
    * 	print Sales
    *	-----------
    */
    	function printSales()
    	{	print("printseller" . CRLF) ; 
    		print_r($this->seller ) ;
     
    		for ($i = 0 ; $i < count($this->seller) ; $i++)
    		{	print($i . " Stamp   [". $this->seller[$i][0]."] => 
    		                Class    [". $this->seller[$i][1]."] => 
    						Ressource[". $this->seller[$i][2]."]" . CRLF ) ;  
    		}
    	}
     
    /**
    * 	add Buyer
    *	------------
    * 	param obj: objname instanciated and having an "notify" property to be get in touch
    * ============================================================================================================================= 
    */
    	function addBuyer( $obj )
    	{	$this->buyer[] = $obj ; }
     
    /**
    * 	add Good to be Buying
    *	----------------------
    * 	param obj: objname instanciated and having an "notify" property to be get in touch
    * ============================================================================================================================= 
    */
    	function addBuying( $time, $who , $method, $item )
    	{	print(' ==>addBuyer[' . $who . '] - [' . $method . '] - [' . $item  . ']' . CRLF) ;
    		$this->buying[] =  array( $time, $who, $method, $item )  ;	
    	}
     
    /**
    * 	remove Buyer
    *	---------------
    */
    	function removeBuyer($obj)
    	{	if ( in_array($this->buyer , $obj) )
    			unset( $this->buyer[$obj] ) ;   
    		else
    			return(false) ;
    	}
     
    /**
    * 	count Buyer
    *	--------------
    */
    	function countBuyer($obj)
    	{	return( count($this->buyer) ) ; }
     
    /**
    * 	print Buyer
    *	--------------
    */
    	function printBuyer()
    	{	print("printBuyer" . CRLF) ; 
    		print_r($this->buyer ) ;
     
    		for ($i = 0 ; $i < count($this->buyer) ; $i++)
    		{	print($i . " seller[". $this->buyer[$i] . CRLF ) ;	}
    	}
     
    /**
    * 	print Sales
    *	-----------
    */
    	function printSelling()
    	{	print("printSelling" . CRLF) ; 
    		print_r($this->buyer ) ;
     
    		for ($i = 0 ; $i < count($this->buyer) ; $i++)
    		{	print($i . " Stamp   [". $this->buyer[$i][0]."] => 
    		                Class    [". $this->buyer[$i][1]."] => 
    						Ressource[". $this->buyer[$i][2]."]" . CRLF ) ;  
    		}
    	}
     
    /**
    * 	display Exception
    *	-----------------
    */
       function display_exception($E)
       {	$T = $E->getTrace() ; 
    	//	======================================================================
    		print("MYsql error diagnostic" .  "<br>\n") ;
    		print("================" .  "<br>\n") ;
    		print("Message: " . $E->getMessage() . " - File: " . $E->getFile() . " - Line: " . $E->getLine() . "<br>\n") ;
    		print("<br>\n") ;
    		print("Trace: " . "<br>\n") ;
    		print("------ " . "<br>\n") ;
    		print( "   => File               : " . $T[0]["file"]     . "<br>\n") ;
    		print( "   => calling instruction: " . $T[0]["line"]     . "<br>\n") ;
     		print( "   => error class        : " . $T[0]["class"]    . "<br>\n") ;
    		print( "   => error function     : " . $T[0]["function"] . "<br>\n") ;
    	//	======================================================================
    		user_error("Catching[connect error in File: " . $T[0]["file"] . "] - line: [" . $T[0]["line"] . "]" , E_USER_ERROR) ;  
    	//	======================================================================
    	}
    }
     
    $Disparcher = new Disparcher() ;
    $Disparcher->addBuyer ( new Buyer ($Disparcher) ) ;
    $Disparcher->addSeller( new Seller($Disparcher) ) ;
     
    //$Disparcher->printSeller() ;
    //$Disparcher->printBuyer() ;
     
    ?>

    Buyer

    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
    <?php
    // =============================================================================================================================== //
    //                                 Class BUYER                                                                                  //
    // =============================================================================================================================== //
    class Buyer
    {	private $Disparcher ;
     
    	function __construct($Disparcher)
    	{ 	$this->Disparcher = $Disparcher ;
    		print("Buyer instanciated" .CRLF) ; 
     
    		$this->Disparcher->execute  (array( microtime() , "addBuying" , "Membre" , "GU_email" )  )  ;  
    		$this->Disparcher->execute  (array( microtime() , "addBuying" , "Membre" , "GU_Membre" )  )  ;  
    	}
     
    	function __destruct() 
    	{ 	print("Buyer destroyed"    .CRLF) ;   }  
     
    	function notify($event)
    	{}
    }
    ?>

    Seller


    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
    <?php
    // =============================================================================================================================== //
    //                                 Class PROVIDER                                                                                  //
    // =============================================================================================================================== //
    class Seller
    {	private $Disparcher ;
     
    	function __construct($Disparcher)
    	{ 	$this->Disparcher = $Disparcher ;
    		print("Seller instanciated" .CRLF) ; 
     
    		$this->Disparcher->execute  (array( microtime() ,  "addSeller" , "Membre" , "GU_email" )  )  ;  
    		$this->Disparcher->execute  (array( microtime() ,  "addSeller" , "Membre", "GU_Member" )  )  ;    
    	}
     
    	function __destruct() 
    	{ print("Seller destroyed"    .CRLF) ;   }  
     
    	function notify($event)
    	{}
     }
    ?>
    Que cela ai déjà été traité, à la limite est secondaire, c'est un exercice pour moi mais j'aimerai bien savoir où cela a été traité, si tu as un exemple, je veux bien.

    Pour le moment mon problème est purement DATA.

    J'ai X sales/buyers avec Y produits/services.

    Il me faut une tableau PHP du style:

    $abc = array
    ('toto" , array("P1","P2") ,
    "tutu , array("P11","P12") ,
    etc
    ) ;

    car l'intersection entre les services et request se fait sur la 2oème partie du tableau 'hors identifiant de l'intervenant.....
    Voilà où j'en suis merci de tes suggestions et corrections éventuelles
    Esteban

  4. #64
    Débutant Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Points : 170
    Points
    170
    Par défaut Class OOP vous avez dit facile ? DB dipatch
    Thomas,

    J'ai travaillé un peu ce WE....
    Et j'ai essayé de simuler et de savoir cmt serait mon Skeleton quand j'aurai intégré des classes de Serveur/Client.
    Ce n'est pas terminé, j'éprouve des difficultés pour supprimer un élémnet d'un tableau associatif quand tu accèdes par la clé.
    J'ai bien compris ton exemple
    $a = array(1 = "TOTO", 2 => 'FIFI'
    Tu souhaites supprimer TOTO et tu sais que la clé est 1, tu fais unset(1)
    Mais si tu ne connais que FIFI, cmt fais-tu ? unset'("FIFI") ne fonctionne pas !
    Et alors que dire si tu passes comme je le souhaiterais à un tableau à 2 dimensions du style:

    $Service = array( $server1 , array("Produit1", ..... "Pn") ,
    $server2 , ...................................
    ) ;

    Enfin j'ai eu peu passer la doc et forum en revue, je n'ai pas trouvé chaussure à mon pied...

    Voici en résumé car j'ai élagué un peu ce que deviendrait mon Skeleton
    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
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    	<?php
    	$PTR_session = session_start() ;
    	
    	require_once $_SERVER['DOCUMENT_ROOT'] . "/class/server.php";  
    	require_once $_SERVER['DOCUMENT_ROOT'] . "/class/service.php";  
    	//require_once $_SERVER['DOCUMENT_ROOT'] . "/class/users.php";  
    	require_once $_SERVER['DOCUMENT_ROOT'] . "/class/magic.php";  
    	// ==========================================================================
    	//		Construct Working and Testing Environnment
    	// ==========================================================================
    	require_once $_SERVER['DOCUMENT_ROOT'] . "/class/newMember.php";  
    	require_once $_SERVER['DOCUMENT_ROOT'] . "/class/newLog.php"; 
    	require_once $_SERVER['DOCUMENT_ROOT'] . "/class/newDB.php";  
    	
    	// ------------------------------------------------------------------------------------------------------------------------------- //	
    	// ------------------------------------------------------------------------------------------------------------------------------- //	
    	// ------------------------------------------------------------------------------------------------------------------------------- //	
    	// ---------------------------------                   INSTANCIATION DU SKELET                   --------------------------------- //	
    	// ------------------------------------------------------------------------------------------------------------------------------- //	
    	// ------------------------------------------------------------------------------------------------------------------------------- //	
    	// ------------------------------------------------------------------------------------------------------------------------------- //	
    	class Container
    	{		private 		$properties = array(), $dbEnv = array() ;
    			private 		$PTR_session, $debug ;
    			public static 	$Kernel, $Environ ;
    			public          $server = array() ;
    	
    	/**
    	* 	Container constructor
    	*
    	*/	
    			public function __construct($PTR_session,$debug)
    			{	$this->PTR_session = $PTR_session ;
    				$this->debug       = $debug ;
    				print("Container Starting" . CRLF) ;
    			}
    	
    			public function execute($box=NULL, $parent=NULL, $param=NULL ) // 	array( $who , $desc , $arg ))
    			{	try {
    						print("Container Executing" . CRLF) ;
    						
    						$dbEnv = Environ::getInstance($utf8=true,$this->debug) ;
    						$this->dbEnv = $dbEnv->getEnviron() ;
    						$this->db = Db::$MYsql ;
    						
    	//			=====================================================================================================================
    	//			A partir de ce point, cela fonctionne, mais les routines vont tjs chercher leurs paramètres dans DB plutôt qu'ENVIRON
    	//			=====================================================================================================================
    						$this->idConn = $this->db->dbConnect($debug=true,$utf8=true,$id='default') ;
    						$this->db->dbSelect($this->dbEnv['base'], $this->idConn ) ;
    				
    						$Sql = "select * from screen where screen = 'index'" ;
    				
    						$this->query = $this->db->dbQuery($Sql, $this->idConn) ;
    						$this->num   = $this->db->dbNumrows($this->query) ;
    				
    						$this->row = $this->db->dbfetchRows($this->query) ;
    						foreach ($this->row as $key => $value)
    						{	print("Key[".$key."] => Value[".$value."]" . CRLF ) ; }
    	//			=====================================================================================================================
    	//			Instantiation de 2 classes pour raison de test du Dispatcher
    	//			=====================================================================================================================
    	/**
    	* 					Instanciation de la classe Member
    	*       			---------------------------------
    	*/
    						if ($this->debug)
    							{	print("==========> Instanciating Member" . CRLF );
    							}
    						$this->member = new Member($this->db, $this->debug) ;
    						$this->member->execute() ;     						// donne un user_error dans le log.php
    	/**
    	* 					Instanciation de la classe Logging
    	*       			----------------------------------
    	*/
    						if ($this->debug)
    							{	print("==========> Instanciating Logging" . CRLF );
    							}
    						$this->logging = new Logging($this->db, $this->debug) ;
    						$this->logging->execute() ;     						// donne un user_error dans le log.php
    	//			=====================================================================================================================
    	//			Enregistrement de ces 2 classes auprès du Dispatcher et execution de celui-ci
    	//			=====================================================================================================================
    						$this->dispatcher("addServer",$this->member ,"gu_email" ) ;
    						$this->dispatcher("addServer",$this->logging,"isrt_log" ) ;
    						$this->printServer("After 2 isrts") ;
    						$this->dispatcher("remServer",$this->member ,"gu_email" ) ;
    						$this->printServer("After one remove") ;
    				
    	//			=====================================================================================================================
    				} catch (Exception $e) { 
    						die("SKELETON CONNECTION ERROR: " . $this->display_exception($e) . "<br/>");
    					}
    			}
    			
    	/**
    	* 	Container Destructor
    	*
    	*/	
    			public function __destruct()
    			{
    				print("Container Ending" . CRLF) ;
    			}
    	
    	
    	/**
    	* 	get Db Environnment & handler
    	*
    	*/	
    			function getDBenv()
    			{	return(Environ::$dbEnv) ;}
    			
    			function getDBhandler()
    			{	return(DB::$dbInst ) ; }
    	// =============================================================================================================================== //
    	// ==================================       Fonction de construction de la classe SKELETON        ================================ //
    	// =============================================================================================================================== //
    		function getInstance($PTR_session, $debug=true)
    		{	if (self::$Kernel == NULL)
    				if (self::$Kernel = new Container($PTR_session, $debug=true))
    					if (self::$Kernel->debug)
    						user_error("Constructor Container OK !" , E_USER_NOTICE) ;
    			return(self::$Kernel) ;
    		}
    	// =============================================================================================================================== //	
    	// ===========================================  D I S P A T C H E R  functions =================================================== //	
    	// =============================================================================================================================== //	
    	//			=====================================================================================================================
    	//			A partir de ce point se trouve le coding du dispatcher, les fonctions sont + bas
    	//			=====================================================================================================================
    		function dispatcher($box, $parent,  $param )
    		{	switch($box):
    				case "addServer"  : //"addServer",    $this   , array(NOT USED) 
    									$this->addServer( $parent , $parent,  $param /*server*/      ) ;
    									break ;
    	
    				case "remServer"  : //"remServer",    $this   , array(NOT USED) 
    									$this->remServer( $parent , $parent,  $param/*server*/      ) ;
    									break ;
    											
    	/*										
    						case "addService" :  //"addService",    $this  , array( $desc , $arg )
    											 $this->addService( $parent, $param              ) ;
    											 break ;
    											
    						case "addUsers"   :  $this->addUsers (  $method, $item ) ;
    											 break ;
    											 
    						case "addRequest" :  $this->addRequest( $method, $item ) ;
    											 break ;
    	*/										 
    											
    					endswitch ;
    		}
    	/**
    	* 	Server: ifExistServer
    	*
    	*/	
    		function ifServerExist($servName)
    		{	foreach ($this->server as $key => $val)
    			{	if (strcmp($val,$servName) == 0)
    					return(true) ;
    			}
    			print("Server[".$servName."] (not ?) found ! " .CRLF) ;
    			return(false) ;
    		}
    	/**
    	* 	add Server
    	*	------------
    	* 	param obj: "$server" instanciated and having an "notify" property to be get in touch
    	* =======================================================================================
    	*/
    		function addServer( $server , $parent,  $name   )
    		{	if (!$this->ifServerExist($name))
    				if ( in_array($server, $this->server ) )
    					$this->message("Duplicated Server") ;
    				else
    					{	print("Server[".$name."] ADDED in list" . CRLF) ;
    						$this->server[] = $name ; //$server  ;
    					}
    			$this->printServer("Addserver") ;
    		}
    	/**
    	* 	Server: delete Server
    	*
    	*/	
    		function remServer(  $server , $parent,  $name    )
    		{	if ($this->ifServerExist($name))
    				if ( in_array($server, $this->server ) )
    					return(False) ;
    				else
    					{	print("Server REMOVE from list" . CRLF) ;
    	//???				unset( $this->server[ $server ] ) ;
    						return True ;
    				}		
    			$this->printServer("RemoveServer") ; 
    		}
    		
    		function addService( $server , $parent,  $name   )
    		{	if (!$this->ifServerExist($name))
    				if ( in_array($server, $this->server ) )
    					$this->message("Duplicated Server") ;
    				else
    					{	print("Server[".$name."] ADDED in list" . CRLF) ;
    						$this->server[] = $name ; //$server  ;
    					}
    			$this->printServer("Addserver") ;
    		}
    	/**
    	* Server: print Server list
    	*
    	*/	
    		function printServer($title)
    		{	print("=== printServer[".$title."] ===" . CRLF) ;
    			foreach($this->server as $key => $val)
    				print("key[".$key."] => val[".$val."]" . CRLF ) ; 
    		}
    	// =============================================================================================================================== //
    		function __get($property)
    		{//	user_error("__get used[".$property."]" , E_USER_NOTICE) ;
    			return( (isset($this->properties[$property])) ? $this->properties[$property] : NULL ) ; 
    		}
    		
    		function __set($property, $value)
    		{ // user_error("__set used[".$property."][".$value."]" , E_USER_NOTICE) ;
    			return($this->properties[$property] = $value) ; 
    		}
    	// =============================================================================================================================== //	
    	//
    	// 	End of class: Container
    	//	======================
    	}
    	
    	$skelt = Container::getInstance($PTR_session, $debug=true) ;
    	$skelt->execute() ;
    	?>

    Les fonctions qui nous intéressent directement sont en gras et l'input est:

    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
    Container Starting
    Container Executing
    Key[0] => Value[index]
    Key[1] => Value[Bienvenue sur le site de [Jecrapahute]!]
    Key[2] => Value[Les non-membres désireux de nous contacter sont priés de le faire]
    Key[3] => Value[]
    Key[4] => Value[index]
    Key[5] => Value[Bienvenue sur le site de [Jecrapahute]!]
    Key[6] => Value[0]
    Key[7] => Value[2010-06-01 17:48:31]
    ==========> Instanciating Member
    ==========> Instanciating Logging
    Server[gu_email] (not ?) found !
    Server[gu_email] ADDED in list
    === printServer[Addserver] ===
    key[0] => val[gu_email]
    Server[isrt_log] (not ?) found !
    Server[isrt_log] ADDED in list
    === printServer[Addserver] ===
    key[0] => val[gu_email]
    key[1] => val[isrt_log]
    === printServer[After 2 isrts] ===
    key[0] => val[gu_email]
    key[1] => val[isrt_log]
    Server REMOVE from list
    === printServer[After one remove] ===
    key[0] => val[gu_email]
    key[1] => val[isrt_log]
    Container Ending
    ======> DB Ending
    ici j'ai essayé unset'"gu_email") et PHP m'a envoyé dans les roses !

    Voilà, ce soir j'aurai du temps, j'espère avoir de tes nouvelles.
    J'en arrive à me dire - en généralisant - au'une page du site est un service comme un autre et que s'il fallait faire une bloucle pour lire les msgs entrant, le destructeur de la page devrait envoyer un msg pour arrêter la boucle de lecture (ce qui n'est pas le cas pour le moment)

    Bref, du pain sur la planche mais je souhaite y arriver moi-même !

    Bonne journée.
    Esteban

  5. #65
    Débutant Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Points : 170
    Points
    170
    Par défaut oo
    Olivier,

    Je suis sur ton blog.... et je cherchais (cela fait longtemps....) à faire fonctionner mon debugger sous eclipse et sauf erreur de ma part, je n'ai trouvé que: Configurer Xdebug et eclipse PDT avec Wamp et je n'utilise pas wamp.
    Mais les modifs ne sont pas difficiles.
    De même comme tu me l'avais suggèré, le registery de Zend frameword (pas le complet)... que j'ai trouvé... finalement j'ai le Zend Framework complet d'installer et c'est un programme et non une bibliothèque de classes comme je le croyais !
    Enfin, cela a un avantage, mon Apache démarre tout de suite....
    Finalement, j'ai essayé d'installer PEAR, je dois être bouché à l'émeri ou je fais trop de PC... mais je n'y suis arrivé malgré le tuto mais installation manuelle... Il en existerait une d'automatique sur le site que je n"ai pas trouvé...
    Bref... rien ne va depuis hier...
    Je te laisse avec mes ennuis....
    @+
    Esteban

  6. #66
    Membre expert
    Avatar de ThomasR
    Homme Profil pro
    Directeur technique
    Inscrit en
    Décembre 2007
    Messages
    2 230
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 37
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Décembre 2007
    Messages : 2 230
    Points : 3 972
    Points
    3 972
    Par défaut
    Bonjour,

    merci de prendre en compte ceci si tu ne veux pas voir ce sujet supprimé :
    Pourrais-tu créer un autre sujet à propos de ton nouveau problème car celui-ci est résolu ?

  7. #67
    Débutant Avatar de ETVigan
    Homme Profil pro
    Conseil - Consultant en systèmes d'information
    Inscrit en
    Avril 2010
    Messages
    660
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Gard (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Conseil - Consultant en systèmes d'information
    Secteur : Finance

    Informations forums :
    Inscription : Avril 2010
    Messages : 660
    Points : 170
    Points
    170
    Par défaut OOP SUpplier / Ressource
    Mais je croyais te l'avoir communiquer, je recommence....
    Esteban

+ Répondre à la discussion
Cette discussion est résolue.
Page 4 sur 4 PremièrePremière 1234

Discussions similaires

  1. Réponses: 1
    Dernier message: 31/08/2008, 19h04
  2. variables extern dans les classe
    Par sali lala dans le forum Eclipse
    Réponses: 1
    Dernier message: 09/04/2008, 23h21
  3. Réponses: 7
    Dernier message: 24/01/2007, 10h01
  4. Réponses: 3
    Dernier message: 12/10/2005, 09h23
  5. problème variable extern
    Par HeKaz dans le forum C
    Réponses: 14
    Dernier message: 08/01/2003, 01h44

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo