Autocomplete

[right]سلام

من 2تا جدول به صورت زیر دارم :

contact( id, name , tel ,…, sid){ sid foriegnkey}

user('sid, name , …){sid primary key}

من میخوام از

autocomplete

در یک فرم جستجو استفاده کنم. زمانیکه کاربر نامی را وارد میکند

suggestion

عمل کند.

به این صورت که نام را در هر 2 جدول بگردد.

اما

در کد زیر

join

را نمیپذیرد

[/right]




 public function actionAutoCompleteLookup()

    {

       if(Yii::app()->request->isAjaxRequest && isset($_GET['q']))

       {

            /* q is the default GET variable name that is used by

            / the autocomplete widget to pass in user input

            */

          $name = $_GET['q']; 

                    // this was set with the "max" attribute of the CAutoComplete widget

          $limit = min($_GET['limit'], 50);

          //$n=$_GET['name'];

          $criteria = new CDbCriteria;

          $criteria->condition = '(name LIKE :sterm or t1.name LIKE :sterm)and sid=:s';

          $criteria->params = array(":sterm"=>"%$name%" ,':s'=>yii::app()->session['sid']);

          $criteria->limit = $limit;

         

          echo $criteria;

          $userArray = Contact::model()->with('s')->findAll($criteria);

          

          $returnVal = '';

          foreach($userArray as $userAccount)

          {

             $returnVal .= $userAccount->getAttribute('name').'|'

                                         .$userAccount->getAttribute('idcontact')."\n";

          }

          echo $returnVal;

       }

    }



[right]با تشکر[/right]

[right][rtl][font="Tahoma"]

من هرچی گشتم اصن تو کد شما join پیدا نکردم :huh:

[/font][/rtl][/right]

[right]منم چیزی پیدا نکردم[/right]

[right]سلام دوستان

یک- قسمت

join

با

with

تعریف شده بود

دو- من این مشکل را با

jquery ui

حل کردم نه با کلاسهای خود

yii.

مرسی

[/right]