简体   繁体   中英

Php mysql table column name conflict

Running into an issue here caused by something beyond my control. I am running a DB query on a table I did not create, it has a table column named "end". This is screwing up my foreach loop as it only gets the first instance and then stops on that particular variable.

Here is my current code:

$eventDates = array();
  foreach( $events as $event ) :
    $eventDates[ $event->post_id ] = $event->start; 
    $eventEnd[ $event->post_id ] = $event->end; 
    $eventVenue[ $event->post_id ] = $event->venue;     
endforeach;

The $event->end; is the problem. Is there another way I can output that data that won't cause a conflict?

Try aliasing the column name in the request otherwise.

select end as thisIsTheEnd ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM