title: How To Insert Data From Web Service/xml/json Into Mysql Db Using Ar Model Class
body: <p>i'm new to Yii, still learning and loving it a lot. So the thing is that i have to build a product retrieval system, which is based on Amazon web services.</p>
  
  <p>First i have created the necessary tables to hold the information about the products. Then i've created the model class using the awesome Gii. After that i generated the CRUD using Gii again. Now i'm kinda stuck. So Gii provides a form to let the users populate the tables with the necessary info. Now in my system/app i have no need for a form input, for any of the main tables that would hold the product information. The tables should auto populate with data gathered from Amazon API. Only a few tables can have form related to the input fields.</p>
  
  <p>So can anyone please guide me in the right direction, on how would i start implementing the functionality. Should i remove this code from the corresponding view and write the functionality in the Controller class.</p>
  
  <pre><code>&lt;div class="row"&gt;
  &lt;?php echo $form-&gt;labelEx($model,'type_id'); ?&gt;
  &lt;?php echo $form-&gt;textField($model,'type_id'); ?&gt;
  &lt;?php echo $form-&gt;error($model,'type_id'); ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Or should i generate a separate view files. Right now i can't seem to find any headway. How to start ? What should be the workflow sequence for a typical application built using Yii. Where would i put the business logic? Of course i know that the business logic should always reside within the Controller class as per the MVC paradigm. But should i write all of the application logic in a single controller class.</p>
  
  <p>I've read about modules and components. But the dilemma i'm facing is that i don't know when is the right time to separate the necessary logic into its respective modules or components.</p>
  
  <p>I'm already following the Web Application Developement with Yii and PHP 2nd Edition, and i admit that its a fantastic book. I've read it two times till now. But i'm getting stuck when i get down to build my projects. Just don't know where to start. My application would not follow a similar flow diagram like the book example.</p>
  
  <p>I just want to adhere to the conventions that are set in Yii. I've heard in many places that once you get used to the conventions in Yii your productivity increases hundred folds. So what are the best practices ?</p>
  
  <p>Say::</p>
  
  <pre><code>1) What are the conventions when building an automated/real time system ?
  2) How to initialize the specific controller logic sequence
  3) How to get the most benefit from the CRUD/Model/Module system already built by Gii ?
  </code></pre>