Jump to content
raymeerwijk

ORDER By date

Recommended Posts

I've been working on this since yesterday but i can't get this to work like i want it too.

I just want the results to order by date ascending instead of chronological order.
My knowledge is really terrible and i have tried a several number of options.

The only result is a page that keeps on loading.

This is why i would like to ask for some help.

I added an image of the things i have and the code is below

    public function getCustomerAppointments( $with_cancelled = false )
    {
        $result = array();

        if ( $this->get( 'id' ) ) {
            $appointments = CustomerAppointment::query( 'ca' )
                ->select( 'ca.*, c.name, c.phone, c.email' )
                ->leftJoin( 'Customer', 'c', 'c.id = ca.customer_id' )
                ->where( 'ca.appointment_id', $this->get( 'id' ) );
            if ( ! $with_cancelled ) {
                $appointments->whereNot( 'ca.status', Lib\Entities\CustomerAppointment::STATUS_CANCELLED );
                $appointments->whereNot( 'ca.status', Lib\Entities\CustomerAppointment::STATUS_REJECTED );
            }

            foreach ( $appointments->fetchArray() as $data ) {
                $ca = new CustomerAppointment( $data );

                // Inject Customer entity.
                $ca->customer = new Customer();
                $data['id']   = $data['customer_id'];
                $ca->customer->setFields( $data, true );

                $result[] = $ca;
            }
        }

        return $result;
    }

Hope you can help me

Ray

post-205388-0-09611800-1505587759_thumb.jpg

Edited by raymeerwijk

Share this post


Link to post
Share on other sites

Based on how you're building your query, there's probably an ->orderby() method that you need to use. Kind of hard to get more specific than that without knowing what your database abstraction layer is doing.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.