Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks
Bibliothèques et frameworks Forum d'entraide sur les frameworks, templates, bibliothèques de code (PDFLib, eZPdf, JpGraph, Artichow, PEAR, etc). Avant de poster : FAQ bibliothèques, toutes les FAQ PHP et cours bibliothèques
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 20/12/2011, 16h14   #1
Invité de passage
 
Inscription : décembre 2011
Messages : 4
Détails du profil
Informations forums :
Inscription : décembre 2011
Messages : 4
Points : 0
Points : 0
Par défaut CodeIgniter/Doctrine - Création d'un model

Bonjour, je m'arrache les cheveux depuis ce matin a ajouter une table de liaison sur un outil basé sur codeigniter.

Je pense avoir correctement définir la table dans le fichier yml et avoir correctement défini la table dans mon model. Pourtant lorsque j'appelle cet objet j'obtiens la magnifique erreur :

Code :
Doctrine_Record_UnknownPropertyException: Unknown method UserInCategory::_assign_libraries in /Volumes/HD_Raid5/Docs en partage/htdocs/system/database/doctrine/Doctrine/Record.php on line 2658
Le contenu de mon yml est assez conséquent, je vais mettre ici uniquement les tables impactées :

Fichier schema.yml :

Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
CampaignCategory:
  tableName: campaign_category
  columns:
    [...]
  relations:
    [...]
    UserInCategory:
      type: many
      local: id
      foreign: category_id
    CategoryUser:
      type: many
      foreignAlias: Categories
      class: User
      refClass: UserInCategory
      foreign: category_id
      local: id
Code :
1
2
3
4
5
6
7
8
9
10
11
 
User:
  tableName: user
  columns:
    [...]
  relations:
    UserInCategory:
      type: many
      local: id
      foreign: category_id  
      [...]
Code :
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
 
UserInCategory:
  tableName: user_in_category
  columns:
    id:
      type: integer(9)
      fixed: false
      unsigned: false
      primary: true
      autoincrement: true
    user_id:
      type: integer(9)
      fixed: false
      unsigned: false
      primary: false
      notnull: true
      autoincrement: false
    category_id:
      type: integer(9)
      fixed: false
      unsigned: false
      primary: false
      notnull: false
      autoincrement: false
  relations:
    User:
      foreignAlias: UserInCategory
      local: user_id
    CampaignCategory:
      foreignAlias: UserInCategory
      local: category_id
Modele de base :

Relation ajouté dans le model user :
Code :
1
2
3
4
5
6
7
8
9
 
$this->hasMany('UserInCategory', array(
             'local' => 'id',
             'foreign' => 'user_id'));
 
        $this->hasMany('CampaignCategory as Categories', array(
             'refClass' => 'UserInCategory',
             'local' => 'category_id',
             'foreign' => 'id'));
Relation ajouté dans le model CampaignCategory :

Code :
1
2
3
4
5
6
7
8
9
 
$this->hasMany('UserInCategory', array(
             'local' => 'id',
             'foreign' => 'category_id'));
 
        $this->hasMany('User as CategoryUser', array(
             'refClass' => 'UserInCategory',
             'local' => 'id',
             'foreign' => 'category_id'));
Code :
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
 
<?php
 
/**
 * Base_UserInCategory
 * 
 * This class has been auto-generated by the Doctrine ORM Framework
 * 
 * @property integer $id
 * @property integer $user_id
 * @property integer $category_id
 * @property User $User
 * @property UserCategory $UserCategory
 * 
 * @package    ##PACKAGE##
 * @subpackage ##SUBPACKAGE##
 * @author     ##NAME## <##EMAIL##>
 * @version    SVN: $Id: Builder.php 7490 2010-03-29 19:53:27Z jwage $
 */
abstract class Base_UserInCategory extends Doctrine_Record
{
    public function setTableDefinition()
    {
        $this->setTableName('user_in_category');
        $this->hasColumn('id', 'integer', 9, array(
             'type' => 'integer',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => true,
             'autoincrement' => true,
             'length' => '9',
             ));
        $this->hasColumn('user_id', 'integer', 9, array(
             'type' => 'integer',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => true,
             'autoincrement' => false,
             'length' => '9',
             ));
        $this->hasColumn('category_id', 'integer', 9, array(
             'type' => 'integer',
             'fixed' => 0,
             'unsigned' => false,
             'primary' => false,
             'notnull' => false,
             'autoincrement' => false,
             'length' => '9',
             ));
    }
 
    public function setUp()
    {
        parent::setUp();
        $this->hasOne('User', array(
             'local' => 'user_id',
             'foreign' => 'id'));
 
        $this->hasOne('CampaignCategory', array(
             'local' => 'category_id',
             'foreign' => 'id'));
 
    }
}
Loin d'être expert sur le framework codeigniter, j'ai dupliqué une table de liaison existante et adapter mon code en espérant que cela fonctionne. Il semblerait que je rate un truc mais je ne sais quoi.

Si quelqu'un a une idée, je suis preneur !
drak56 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/12/2011, 16h37   #2
Invité de passage
 
Inscription : décembre 2011
Messages : 4
Détails du profil
Informations forums :
Inscription : décembre 2011
Messages : 4
Points : 0
Points : 0
Je viens de trouver une première erreur d'inattention dans le ficher yml sur la table user.
Maintenant cela donne ca :
Code :
1
2
3
4
5
6
7
8
9
10
11
 
User:
  tableName: user
  columns:
    [...]
  relations:
    UserInCategory:
      type: many
      local: id
      foreign: user_id  
      [...]
Mais cela ne fonctionne toujours pas ...
drak56 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/12/2011, 17h01   #3
Invité de passage
 
Inscription : décembre 2011
Messages : 4
Détails du profil
Informations forums :
Inscription : décembre 2011
Messages : 4
Points : 0
Points : 0
Plus je fais de tests et plus je me dis que le problème vient peut etre de ma facon d'appeler le model.

N'ayant pas trouver comment ce faisait le chargement d'un model dans le code existant, j'ai suivi la doc et ajouté un :

Code :
$this->load->model('UserInCategory');
Au dessus de mon code dans le controller, le problème peut-il venir de cet appel différent des autres ?
drak56 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 20/12/2011, 17h15   #4
Invité de passage
 
Inscription : décembre 2011
Messages : 4
Détails du profil
Informations forums :
Inscription : décembre 2011
Messages : 4
Points : 0
Points : 0
Mon problème est réglé et ne venait pas du .yml.

Sujet Clos.
drak56 est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 20h36.


 
 
 
 
Partenaires

Hébergement Web