Discussion:
[doctrine-user] Unable to retrive Many-To-One Object's data
StarmanW
2018-02-04 06:42:51 UTC
Permalink
I'm still a novice to PHP and ORM stuff. I am trying to get an associative
object's data through the getter method. An event may contain 0 or more
collaborators. So for example, event "E0001" have 2 collaborators, I want
to retrieve that 2 collaborators' details and display it in the webpage.


However, an "Uncaught Error: Call to a member function getCollabID() on
string" error occurred when I invoked the "getCollabByEventID("E0001")"
method in "EventCollaboratorService.php".


The relationships for Events and Collaborators are illustrated in this link:

Loading Image...


<https://i.gyazo.com/a60f671989983325c94ab60e5fdfbad5.png>

Codes:

Event.php: https://pastebin.com/ynkWQfhR

Collaborator.php: https://pastebin.com/LNgVQ8H7

EventCollaborator.php: https://pastebin.com/CQtKbrim

EventCollaboratorService.php: https://pastebin.com/vQz6x8Bp


<https://pastebin.com/vQz6x8Bp>
<?php
$eventCollabs = new EventCollaboratorService();
$eventCollabs = $eventCollabs->getCollabByEventID($_GET['e']);
?>
<table>
<thead>
<tr><th>Collaborator ID</th></tr>
....
</thead>
<tbody>
<tr><td><?php echo $eventCollabs[$i]->getCollaborator()->getCollabID(); ?></td></tr>
<tr><td><?php echo $eventCollabs[$i]->getCollaborator()->getCollabName(); ?></td></tr>
<tr><td><?php echo $eventCollabs[$i]->getCollaborator()->getCollabTypeString(); ?></td></tr>
....
</tbody>
</table>
The records are unable to link to Collaborator.php. Which part did I did
wrong? Thank you.
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+***@googlegroups.com.
To post to this group, send email to doctrine-***@googlegroups.com.
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.
Marco Pivetta
2018-02-07 22:23:42 UTC
Permalink
Heya!

Can you maybe move all the examples to a stable gist on gist.github.com?
The pastebin entries you uploaded are no longer available...

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/
Post by StarmanW
I'm still a novice to PHP and ORM stuff. I am trying to get an associative
object's data through the getter method. An event may contain 0 or more
collaborators. So for example, event "E0001" have 2 collaborators, I want
to retrieve that 2 collaborators' details and display it in the webpage.
However, an "Uncaught Error: Call to a member function getCollabID() on
string" error occurred when I invoked the "getCollabByEventID("E0001")"
method in "EventCollaboratorService.php".
https://i.gyazo.com/a60f671989983325c94ab60e5fdfbad5.png
<https://i.gyazo.com/a60f671989983325c94ab60e5fdfbad5.png>
Event.php: https://pastebin.com/ynkWQfhR
Collaborator.php: https://pastebin.com/LNgVQ8H7
EventCollaborator.php: https://pastebin.com/CQtKbrim
EventCollaboratorService.php: https://pastebin.com/vQz6x8Bp
<https://pastebin.com/vQz6x8Bp>
<?php
$eventCollabs = new EventCollaboratorService();
$eventCollabs = $eventCollabs->getCollabByEventID($_GET['e']);
?>
<table>
<thead>
<tr><th>Collaborator ID</th></tr>
....
</thead>
<tbody>
<tr><td><?php echo $eventCollabs[$i]->getCollaborator()->getCollabID(); ?></td></tr>
<tr><td><?php echo $eventCollabs[$i]->getCollaborator()->getCollabName(); ?></td></tr>
<tr><td><?php echo $eventCollabs[$i]->getCollaborator()->getCollabTypeString(); ?></td></tr>
....
</tbody>
</table>
The records are unable to link to Collaborator.php. Which part did I did
wrong? Thank you.
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to doctrine-user+***@googlegroups.com.
To post to this group, send email to doctrine-***@googlegroups.com.
Visit this group at https://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/d/optout.
Loading...