Fungsi Search Relation

Ada kesulitan nih saya,

Saya punya relasi :

item


rItemPrice = array(self::HAS_MANY,‘ItemPrice’,‘item_id’),

item_price


rItemPrice = array(self::BELONGS_TO, ‘Item’,‘item_id’),

search()


$criteria->with=‘rItemPrice’;

$criteria->compare(‘rItemPrice.price’, $this->price, true);

kok aneh yah, left outer joinnya gak jalan

tolong dunk

thanks

sepertinya begini tuh gan…




$criteria->with='rItemPrice';

$criteria->compare('rItemPrice.price', $this->rItemPrice ->price, true);



Masih bermasalah … seperti tidak di compare … datanya sama saja

salah dimana yah :)

gan sudah coba di debug sbelum dicompare




var_dump( $this->atributes );


//atau




var_dump($this->itemPrice->attributes);

//ingat itemprice itu relasi has many, jadi harus direkrusi



ada lagi trik ampuh untuk debug, aktifkan mysql query log, dan agan bisa chek langsung disana apapkah query yang dihasilkan sudah seperti yg agan harapkan…

trims.

Masalahnya mirip dengan punyaku gan. Jadi saya ingin merelasikan tabel user dengan tabel pengalaman_kerja di mana user HAS_MANY pengalaman_kerja dan pengalaman_kerja BELONGS_TO user.




//model User.php

'pengalaman_kerja' => array(self::HAS_MANY, 'PengalamanKerja', 'id_user'),


//model PengalamanKerja.php

'user' => array(self::BELONGS_TO, 'User', 'id_user'),


// function search()

$criteria->with = array(

  'pengalaman_kerja' => array(

    'alias' => 'pk'

  ),

);

$criteria->compare('pk.posisi', $this->posisi, true);



Kalau kesimpulanku sementara mungkin karena men-joinkan relasi BELONGS_TO dengan HAS_MANY. mungkin agan2 yg punya solusinya


$criteria->with='rItemPrice';

$criteria->compare('rItemPrice.price', $this->id_rItemPrice, true);

id_rItemPrice nya di sesuain ma primary key table rItemPrice