Y
Y
Yura Komarov2018-02-19 21:16:25
PHP
Yura Komarov, 2018-02-19 21:16:25

How to get such assoc aray in one mysql fetch?

Good evening everyone.
To business. Selected from the table the data and received an array. Then foreach went through this array and got data for the id of one table from another, docked them in this loop, and the output turned out to be what I need.

Array
(
    [0] => Array
        (
            [dogovor_id] => 9
            [dogovor_number] => 1-2018
            [date_start] => 2018-02-06 17:15:00
            [dogovor_object] => Канцелярия
            [customer_id] => 10
            [dogovor_action] => Array
                (
                    [0] => Array
                        (
                            [price] => 3500
                            [responsible] => 2
                            [performer] => 3
                            [date_add] => 2018-02-19 20:07:00
                            [date_start] => 2018-02-20 20:07:00
                            [date_end] => 2018-02-22 20:07:00
                            [date_final] => 2018-02-27 20:07:00
                            [status] => Ожидает
                        )

                    [1] => Array
                        (
                            [price] => 3000
                            [responsible] => 3
                            [performer] => 2
                            [date_add] => 2018-02-23 20:09:00
                            [date_start] => 2018-02-25 20:09:00
                            [date_end] => 2018-02-26 20:09:00
                            [date_final] => 2018-02-28 20:09:00
                            [status] => На реализации
                        )

                )

        )

    [1] => Array
        (
            [dogovor_id] => 12
            [dogovor_number] => 2-2018
            [date_start] => 2018-02-16 18:19:06
            [dogovor_object] => 
            [customer_id] => 10
         )

)

Is it possible to get such an array in one sample, what kind of query should be in the database.
Thanks to all

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2018-02-19
@Yurajun

no way, the result is a one-dimensional array. you can really glue the subarray into a string with concat

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question