Yii Framework Forum: [ASK]CDbCriteria/Model - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[ASK]CDbCriteria/Model Rate Topic: -----

#1 User is offline   kfahmi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 81
  • Joined: 19-March 12

Posted 15 May 2012 - 04:38 AM

Masterrrrrr

ini ada sedikit query,

mau cari ke model EMP buat dapetin email-email pegawai yang 1 divisi dan levelnya lebih rendah.

pake cDb criteria, yang buat bingung, gimana ya caranya looping buat set variable $to nya, pake for each, atau each

sorry kalo jelasinnya gak bener, soalnya pemula


//ERRORNYA CANNOT CONVERT OBJECT CLASS INTO STRING
codenya dibawah ini


$criteria=new CDbCriteria;
$criteria->condition='id_lev<:idLev AND id_div=:idDiv';
$criteria->params=array(':idLev'=>$level,':idDiv'=>$divisi);
 $cariMail=Emp::model()->findAll($criteria); 
 
 $to = "someone@domain.com";
              
 while(list($key, $mail) = each ($cariMail)
{                              
    $to .= ", "."$mail"; 
}

//ERRORNYA CANNOT CONVERT OBJECT CLASS INTO STRING
 

0

#2 User is offline   angela88 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 144
  • Joined: 14-October 11
  • Location:Jakarta

Posted 15 May 2012 - 05:18 AM

View Postkfahmi, on 15 May 2012 - 04:38 AM, said:

Masterrrrrr

ini ada sedikit query,

mau cari ke model EMP buat dapetin email-email pegawai yang 1 divisi dan levelnya lebih rendah.

pake cDb criteria, yang buat bingung, gimana ya caranya looping buat set variable $to nya, pake for each, atau each

sorry kalo jelasinnya gak bener, soalnya pemula


//ERRORNYA CANNOT CONVERT OBJECT CLASS INTO STRING
codenya dibawah ini


$criteria=new CDbCriteria;
$criteria->condition='id_lev<:idLev AND id_div=:idDiv';
$criteria->params=array(':idLev'=>$level,':idDiv'=>$divisi);
 $cariMail=Emp::model()->findAll($criteria); 
 
 $to = "someone@domain.com";
              
 while(list($key, $mail) = each ($cariMail)
{                              
    $to .= ", "."$mail"; 
}

//ERRORNYA CANNOT CONVERT OBJECT CLASS INTO STRING
 


kalo gini??

$criteria=new CDbCriteria;
$criteria->condition='id_lev<:idLev AND id_div=:idDiv';
$criteria->params=array(':idLev'=>$level,':idDiv'=>$divisi);
 $cariMail=Emp::model()->findAll($criteria); 
 
 $to = "someone@domain.com";
 foreach($cariMail as $m):
   $to .= ", ".$m->mail;
 endforeach;            
 

$m->mail = field mail dari tabel emp..
q ga tau field yg diambil apa jadi q cuma kira2...
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users