[Help] as I can show results of a query?

Hello me code is the next.

I know that it is wrong but i need help for show result of one query of search.

Sorry me english is bad

Method that in the SiteController







 public function actionAbout()

    {

       

        

        $form= new formBusqueda;

        $search = null;

        

        if($form->load(Yii::$app->request->get()))

        {

            if ($form->validate())

            {

                 $search = Html::encode($form->q);

               

                 $query = new Query;

                 $query	 ->select(['t_complejos.id_complejos'])  

		         ->from('t_complejos')

		         ->join(	'INNER JOIN', 

				't_canchas',

				't_canchas.id_cancha = t_complejos.id_complejos'

			); 


$model = $query->createCommand();

$model = $command->queryAll();	

                 

                 

                 

                 

                

            }

            else

            {


                $form->getErrors();

            }


        }

        return $this->render("about", ["model"=>$model, "form"=>$form, "search"=>$search]);

    }




View





 <?= $f->field($form, "q")->input("search") ?>

    

    <?= Html::submitButton("buscar", ["class" => "btn btn-primary"]) ?>


</div>

<?php $f->end() ?>







Model





<?php

namespace app\models;

use Yii;

use yii\db\ActiveRecord;


class t_complejos extends ActiveRecord {


	public static function getDb()

	{

		return Yii::$app->db;


	}


	public static function tableName()

	{

		return 't_complejos';

	}


}
















<?php

namespace app\models;

use Yii;

use yii\db\ActiveRecord;


class T_canchas extends ActiveRecord {


	public static function getDb()

	{

		return Yii::$app->db;


	}


	public static function tableName()

	{

		return 't_canchas';

	}


}
















what error are you encountering??? Sorry but i couldn’t understand what u meant.

My code is wrong conceptually.

I want to know how to display MySQL queries in Yii 2.

want an easy example to understand please.

You can you give me an example? Please

My link check out this link, and this one too My link

I might be wrong. If you are already familiar with the standard way of handling database in Yii framework, please ignore the following.

IMO, the most useful code examples come from Gii … "Model Generator" and "CRUD Generator".

  1. Create your database tables.

  2. Create ActiveRecord models for the tables using Gii’s Model Generator.

  3. Create CRUD pages for the models using Gii’s CRUD Generator.

  4. Examine carefully the generated code, then you will learn the standard way of working with databases in Yii framework.

yes i saw this but i want see one example complete,model,controller y view.

I only see query but i dont know call to view