vipinc  
            (Vipin7873)
           
           
          
              
                November 19, 2012,  6:58am
               
               
          1 
           
         
        
          Hi,
How do I handle Variable Variable($$) in Active Record output?
For Ex.
$qdata = $qmodel->findByAttributes(array("q_id"=>$testqs[0]->q_id));
$qcorrect = "answer".$qdata->correct_answer;
I need $qdata->answer1. But the value 1 is dynamic based on what is passed.
$qdata->$$qcorrect does not work.
Thanks,
Vipin
         
         
           
        
            
            
            
         
         
             
             
          
       
      
        
          
          
            traprajith  
            (Traprajith)
           
           
          
              
                November 19, 2012,  7:42am
               
               
          2 
           
         
        
          didnt get ur doubt!!
anyway u need this? $qdata->qcorrect ?
after this , $qdata = $qmodel->findByAttributes(array("q_id"=>$testqs[0]->q_id));
$qdata is an array…u can use like ,$qdata->q_id, $qdata->ur_attribute_here etc…
         
         
        
            
            
            
         
         
             
             
          
       
      
        
          
          
            redguy  
            (Maciej Lizewski)
           
           
          
              
                November 19, 2012,  7:52am
               
               
          3 
           
         
        
          
Hi,
How do I handle Variable Variable($$) in Active Record output?
For Ex.
$qdata = $qmodel->findByAttributes(array("q_id"=>$testqs[0]->q_id));
$qcorrect = "answer".$qdata->correct_answer;
I need $qdata->answer1. But the value 1 is dynamic based on what is passed.
$qdata->$$qcorrect does not work.
Thanks,
Vipin
 
 
you should use it like this:
$qdata->$qcorrect; //only one $ sign if $qcorrect variable holds the attribute name.
 
         
         
        
            
            
            
         
         
             
             
          
       
      
        
          
          
            _uJJwAL  
            (_uJJwAL_)
           
           
          
              
                November 19, 2012, 10:34am
               
               
          4 
           
         
        
          Your post does not seem to be much clear as to what is $qdata - answer1 and you mean 1 is the variable passed. Anyway, whatever you are trying to get from the query if the value is the column value in the database; that should be easily fetched as $qdata -> column_name. or iterate foreach loop as the result is the array.