Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Bonjour,
je rencontre un pb que je n'arrive décidément pas à résoudre.
J'ai 2 tables : artistes et songs. Les relations sont assez évidentes, les artistes sont parents des chansons.
ma classe artistes :
class Artistes extends Zend_Db_Table_Abstract { /* Nom de la table */ protected $_name = 'artistes'; /* Clé primaire */ protected $_primary = 'id'; /* Nom des table enfants */ protected $_dependentTables = array('Songs');
ma classe songs
class Songs extends Zend_Db_Table_Abstract { protected $_name = 'chansons'; protected $_primary = 'id'; protected $_referenceMap = array( 'Interprete' => array( 'columns' => 'id_artiste', 'refTableClass' => 'Artistes', 'refColumns' => 'id' ) );
J'ai un objet artiste, d'où j'appelle la méthode findDependentRowset, afin d'avoir les chansons affiliées.
$table = new Artistes(); $artistrowset = $table->find('5'); // pour exemple $artist = $artistrowset->current(); // $artist contient l'objet zend..._row. return $artist->findDependentRowset('Songs');
Et là j'ai l'erreur :
Zend_Db_Table_Row_Exception: File "Songs.php" does not exist or class "Songs" was not found in the file
#0 C:\wamp\www\coverchords\application\models\Artistes.php(57): Zend_Db_Table_Row_Abstract->findDependentRowset('Songs')
#1 C:\wamp\www\coverchords\application\controllers\ArtistController.php(53): Model_Artistes->listSongs('5')
#2 C:\wamp\www\coverchords\library\Zend\Controller\Action.php(503): ArtistController->songslistAction()
#3 C:\wamp\www\coverchords\library\Zend\Controller\Dispatcher\Standard.php(285): Zend_Controller_Action->dispatch('songslistAction')
#4 C:\wamp\www\coverchords\library\Zend\Controller\Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#5 C:\wamp\www\coverchords\public\index.php(44): Zend_Controller_Front->dispatch()
#6 {main}
Pourtant mon fichier existe bien, il se situe dans /application/models/DbTable/, le nom de la classe est bon.
Tiens juste pour me marrer, j'ai copié Songs.php un peu partout dans l'arbo... et dans public ça marche !
Y a quelquechose à changer concernant la convention d'arborescence ?
Merci pour votre aide.
Dernière modification par supertino7 (04-03-2009 04:04:35)
Hors ligne
Si tu veux que ton fichier soit automatiquement inclus, tu dois ajouter ton dossier /application/models/DbTable/ dans l'include path comme ceci:
set_include_path( '../application/models/DbTable/' . PATH_SEPARATOR . get_include_path() );
Hors ligne
3uclide a écrit:
Si tu veux que ton fichier soit automatiquement inclus, tu dois ajouter ton dossier /application/models/DbTable/ dans l'include path comme ceci:
Code:
set_include_path( '../application/models/DbTable/' . PATH_SEPARATOR . get_include_path() );
aaah d'accord.
et ça m'eviterait egalement d'avoir recours à require_once à l'interieur de mes classes (comme on fait pour débuter avec le quickstart)
Merci
Pendant que j'y suis , est ce qu'il existe une méthode magique qui evite de devoir instancier le modele, en tout cas qui permette d'avoir automatiquement accès au modele, sans devoir créer un paramètre + une function qui fasse un new... ?
Hors ligne