1

Hey guys I am trying to get a value from an array in my events_controller.php file. Event belongsTo Entity and Entity hasMany Event. I need this value to perform some other logic but im really stuck and i know it should be an easy thing to do.

I am trying to get the value of Entity.user_id from this array.

Array
(
[Event] => Array
    (
        [id] => 19
        [entity_id] => 8
        [name] => new event
        [time_start] => 2011-02-26 19:09:00
        [time_end] => 2011-02-26 19:09:00
        [dateStart] => 0000-00-00
        [dateEnd] => 0000-00-00
        [description] => jgiuguygo
        [ageRange] => 67
    )

[Entity] => Array
    (
        [id] => 8
        [user_id] => 14
        [location_id] => 15
        [type] => EVENT
    )

[Eventfeedback] => Array
    (
    )
)

the above matrix i obtained with this code:

$value = $this->Event->read();
pr($value);

Now this is as close as I can get...

Array
(
[Entity] => Array
    (
        [user_id] => 14
    )

[Event] => Array
    (
        [id] => 19
    )

[Eventfeedback] => Array
    (
    )
)

with this code

$value = $this->Event->read('Entity.user_id');
pr($value);

An last try i got this array

Array
(
[Entity] => Array
    (
        [id] => 1
        [user_id] => 11
        [location_id] => 8
        [type] => sdfsdfdsf
    )

[User] => Array
    (
        [id] => 11
        [firstName] => luis
        [lastName] => pooya
        [username] => admin
        [password] => 94c882c8506497a9f031ca5a4db6d0143c97fe45
        [role] => admin
        [email] => some
    )

[Location] => Array
    (
        [id] => 8
        [name] => First Nation University of Canada
        [xCoordinate] => 0
        [yCoordinate] => 0
    )

[Establishment] => Array
    (
    )

[Event] => Array
    (
    )

[Vmachine] => Array
    (
    )
)

with this code

$value = $this->Event->Entity->find('user_id');
pr($value);

Hope someone can help me out. Thanks in advance.Luis

2 Answers 2

2

I'm not sure I understood you correctly. But to get user_id in your examples would be like

$value = $this->Event->read('Entity.user_id');
pr($value['Entity']['user_id']);
Sign up to request clarification or add additional context in comments.

Comments

2
$event = $this->Event->read();
$userId = $event['Entity']['user_id'];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.