<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://sugarclub.sugarcrm.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>What is the right way to Fetch data from DB in Logic Hook for On Premise and OnLine).</title><link>https://sugarclub.sugarcrm.com/dev-club/f/questions-answers/605/what-is-the-right-way-to-fetch-data-from-db-in-logic-hook-for-on-premise-and-online</link><description>Hi Team, Following is my Use case for Both Version(On Line and On Premise). ------------------------------------------------------------------------------------------ I want to read All accounts(Module) from the DB When user fire an event called Before</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: What is the right way to Fetch data from DB in Logic Hook for On Premise and OnLine).</title><link>https://sugarclub.sugarcrm.com/thread/2071?ContentTypeID=1</link><pubDate>Tue, 09 Aug 2016 07:17:14 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:620cc55e-fec2-4c35-b3db-4f4c31995de9</guid><dc:creator>Ramana Raju Santhana</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://sugarclub.sugarcrm.com/members/parag.mittal_4000_pb.com"&gt;Parag Mittal&lt;/a&gt;&lt;/p&gt;&lt;p&gt;You can use SugarQuery then.&lt;/p&gt;&lt;p&gt;If you want to do it with WebServices then check this link:&lt;/p&gt;&lt;p&gt;&lt;a href="http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Application_Framework/Web_Services/Examples/SOAP/PHP/Retrieving_a_List_of_Records/" rel="nofollow" target="_blank"&gt;http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Application_Framework/Web_Services/E&amp;hellip;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;a href="http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Application_Framework/Web_Services/Examples/SOAP/PHP/Creating_or_Updating_a_Record/" rel="nofollow" target="_blank"&gt;http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_6.5/Application_Framework/Web_Services/E&amp;hellip;&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;Hope this Helps..!!&lt;/p&gt;&lt;p&gt;Best Regards&lt;/p&gt;&lt;p&gt;S Ramana Raju&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What is the right way to Fetch data from DB in Logic Hook for On Premise and OnLine).</title><link>https://sugarclub.sugarcrm.com/thread/2070?ContentTypeID=1</link><pubDate>Mon, 08 Aug 2016 13:21:21 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:72e4f906-d897-4e54-9646-33978c2ffd9c</guid><dc:creator>Parag Mittal</dc:creator><description>&lt;p&gt;Hi Ramana,&lt;/p&gt;&lt;p&gt;Hope you are doing well!&lt;/p&gt;&lt;p&gt;I am able to read and update data from DB with the above mentioned example. But i do not want to perform crud operation direct with DB as it is not good practice. is there any SDK or API available to perform CRUD&amp;nbsp;operation for ON Premise version.&lt;/p&gt;&lt;p&gt;Could you please share any example for on premise.&lt;/p&gt;&lt;p&gt;Regards,&lt;/p&gt;&lt;p&gt;Deepak&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What is the right way to Fetch data from DB in Logic Hook for On Premise and OnLine).</title><link>https://sugarclub.sugarcrm.com/thread/2069?ContentTypeID=1</link><pubDate>Mon, 25 Jul 2016 13:16:09 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:689044b2-8fb5-4d76-a24e-3aa593185f5d</guid><dc:creator>Sam Roy</dc:creator><description>&lt;p&gt;Hello &lt;a href="https://sugarclub.sugarcrm.com/members/parag.mittal_4000_pb.com"&gt;Parag Mittal&lt;/a&gt;&lt;/p&gt;&lt;p style="font-size:14px;color:#000000;"&gt;We can give appreciation by clicking like, Helpful and if it really worked then mark that post as Answer as Correct..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What is the right way to Fetch data from DB in Logic Hook for On Premise and OnLine).</title><link>https://sugarclub.sugarcrm.com/thread/2068?ContentTypeID=1</link><pubDate>Mon, 25 Jul 2016 12:54:39 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:cc6d8896-f8b4-4a48-9c0a-4534a31c332a</guid><dc:creator>Parag Mittal</dc:creator><description>&lt;p&gt;Thanks Ramana.&lt;/p&gt;&lt;p&gt;Its working.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What is the right way to Fetch data from DB in Logic Hook for On Premise and OnLine).</title><link>https://sugarclub.sugarcrm.com/thread/2067?ContentTypeID=1</link><pubDate>Mon, 25 Jul 2016 10:19:00 GMT</pubDate><guid isPermaLink="false">5c521d64-519d-47a6-9065-134618b211bf:3bb59b5a-ce6c-4382-9379-77d1098a1488</guid><dc:creator>Ramana Raju Santhana</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://sugarclub.sugarcrm.com/members/parag.mittal_4000_pb.com"&gt;Parag Mittal&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Once check this code:&lt;/p&gt;&lt;pre class="php"&gt;$db = DBManagerFactory::getInstance();
&amp;nbsp; 
&amp;nbsp; $query = &amp;quot;SELECT * FROM accounts WHERE deleted = 0&amp;quot;;
&amp;nbsp; $result = $db-&amp;gt;query($query, true,&amp;quot;Error reading number of accounts: &amp;quot;);
&amp;nbsp; while( $row = $db-&amp;gt;fetchByAssoc($result)){
&amp;nbsp; // Do what ever manupulation you want do it here
&amp;nbsp; $module = &amp;quot;Accounts&amp;quot;;
&amp;nbsp; $id = $row['id'];
&amp;nbsp; $bcontact = BeanFactory::newBean($module);
&amp;nbsp; $bcontact-&amp;gt;db-&amp;gt;query(&amp;quot;UPDATE accounts SET database-fieldname =&amp;#39;&amp;quot;.$row['field-name'].&amp;quot;&amp;#39; WHERE id=&amp;#39;&amp;quot;.$id.&amp;quot;&amp;#39;&amp;quot;);
&amp;nbsp; }
&amp;nbsp; $bean-&amp;gt;approved_declined_c = $bean-&amp;gt;modified_by_name;&amp;nbsp; 
&amp;nbsp; $bean-&amp;gt;save();
&lt;/pre&gt;&lt;div style="display:none;"&gt;&lt;/div&gt;&lt;p&gt;you can also get through &lt;a href="http://support.sugarcrm.com/Documentation/Sugar_Developer/Sugar_Developer_Guide_7.5/API/Classes/SugarQuery/" rel="nofollow" target="_blank"&gt;SugarQuery&lt;/a&gt;&lt;/p&gt;&lt;p&gt;Hope this Helps&lt;/p&gt;&lt;p&gt;Best Regards&lt;/p&gt;&lt;p&gt;S Ramana Raju&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>