Error: Call to a member function beginTransaction()












0















I have created a custom module "adminform" with some custom fields when i try to save my form data it gives the error




"Call to a member function beginTransaction()"




I have the following form fields:



protected function _prepareForm()
{
$form = new Varien_Data_Form(array(
'id' => 'edit_form',
'action' => $this->getUrl('*/*/save'),
'method' => 'post',
));

$form->setUseContainer(true);
$this->setForm($form);

$helper = Mage::helper('optfirst_reviewmycompany');
$fieldset = $form->addFieldset('display', array('legend' => $helper->__('Select Social Icons'),
'class' => 'fieldset-wide'));

$fieldset->addField('facebook', 'text', array(
'name' => 'facebook',
'label' => $helper->__('Facebook'),
));
$fieldset->addField('google', 'text', array(
'name' => 'google',
'label' => $helper->__('Google'),
));
$fieldset->addField('twitter', 'text', array(
'name' => 'twitter',
'label' => $helper->__('Twitter'),
));
$fieldset->addField('linkedin', 'text', array(
'name' => 'linkedin',
'label' => $helper->__('Linkedin'),
));
$fieldset->addField('yelp', 'text', array(
'name' => 'yelp',
'label' => $helper->__('Yelp'),
));


if (Mage::registry('optfirst_reviewmycompany')) {
$form->setValues(Mage::registry('optfirst_reviewmycompany')->getData());
}

return parent::_prepareForm();
}


And following is my Saveaction method in controller:



 public function saveAction()
{

//$data = $this->getRequest()->getParams();
if ( $data = $this->getRequest()->getParams() ) {

$this->_getSession()->setFormData($data);
$model = Mage::getModel('optfirst_reviewmycompany/review')->setData($data);
//$model = Mage::getModel('optfirst_reviewmycompany/review');
print_r($model->getData());

try {
$insertId = $model->save()->getId();
echo "Data successfully inserted. Insert ID: ".$insertId;
} catch (Exception $e){
echo $e->getMessage();
}

return;
}


Also I have define the model in my configuration file like :



<models>
<optfirst_reviewmycompany>
<class>OptFirst_ReviewMyCompany_Model</class>
<resourceModel>optfirst_reviewmycompany_resource</resourceModel>
</optfirst_reviewmycompany>
<optfirst_reviewmycompany_resource>
<class>OptFirst_ReviewMyCompany_Model_Resource</class>
<entities>
<review>
<table>optfirst_reviewmycompany</table>
</review>
</entities>
</optfirst_reviewmycompany_resource>
</models>


But still no luck with data save to database is there any wrong thing i am doing please check the code and try to find the mistake that where i am doing wrong..



Thanks..










share|improve this question
















bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    I have created a custom module "adminform" with some custom fields when i try to save my form data it gives the error




    "Call to a member function beginTransaction()"




    I have the following form fields:



    protected function _prepareForm()
    {
    $form = new Varien_Data_Form(array(
    'id' => 'edit_form',
    'action' => $this->getUrl('*/*/save'),
    'method' => 'post',
    ));

    $form->setUseContainer(true);
    $this->setForm($form);

    $helper = Mage::helper('optfirst_reviewmycompany');
    $fieldset = $form->addFieldset('display', array('legend' => $helper->__('Select Social Icons'),
    'class' => 'fieldset-wide'));

    $fieldset->addField('facebook', 'text', array(
    'name' => 'facebook',
    'label' => $helper->__('Facebook'),
    ));
    $fieldset->addField('google', 'text', array(
    'name' => 'google',
    'label' => $helper->__('Google'),
    ));
    $fieldset->addField('twitter', 'text', array(
    'name' => 'twitter',
    'label' => $helper->__('Twitter'),
    ));
    $fieldset->addField('linkedin', 'text', array(
    'name' => 'linkedin',
    'label' => $helper->__('Linkedin'),
    ));
    $fieldset->addField('yelp', 'text', array(
    'name' => 'yelp',
    'label' => $helper->__('Yelp'),
    ));


    if (Mage::registry('optfirst_reviewmycompany')) {
    $form->setValues(Mage::registry('optfirst_reviewmycompany')->getData());
    }

    return parent::_prepareForm();
    }


    And following is my Saveaction method in controller:



     public function saveAction()
    {

    //$data = $this->getRequest()->getParams();
    if ( $data = $this->getRequest()->getParams() ) {

    $this->_getSession()->setFormData($data);
    $model = Mage::getModel('optfirst_reviewmycompany/review')->setData($data);
    //$model = Mage::getModel('optfirst_reviewmycompany/review');
    print_r($model->getData());

    try {
    $insertId = $model->save()->getId();
    echo "Data successfully inserted. Insert ID: ".$insertId;
    } catch (Exception $e){
    echo $e->getMessage();
    }

    return;
    }


    Also I have define the model in my configuration file like :



    <models>
    <optfirst_reviewmycompany>
    <class>OptFirst_ReviewMyCompany_Model</class>
    <resourceModel>optfirst_reviewmycompany_resource</resourceModel>
    </optfirst_reviewmycompany>
    <optfirst_reviewmycompany_resource>
    <class>OptFirst_ReviewMyCompany_Model_Resource</class>
    <entities>
    <review>
    <table>optfirst_reviewmycompany</table>
    </review>
    </entities>
    </optfirst_reviewmycompany_resource>
    </models>


    But still no luck with data save to database is there any wrong thing i am doing please check the code and try to find the mistake that where i am doing wrong..



    Thanks..










    share|improve this question
















    bumped to the homepage by Community 9 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I have created a custom module "adminform" with some custom fields when i try to save my form data it gives the error




      "Call to a member function beginTransaction()"




      I have the following form fields:



      protected function _prepareForm()
      {
      $form = new Varien_Data_Form(array(
      'id' => 'edit_form',
      'action' => $this->getUrl('*/*/save'),
      'method' => 'post',
      ));

      $form->setUseContainer(true);
      $this->setForm($form);

      $helper = Mage::helper('optfirst_reviewmycompany');
      $fieldset = $form->addFieldset('display', array('legend' => $helper->__('Select Social Icons'),
      'class' => 'fieldset-wide'));

      $fieldset->addField('facebook', 'text', array(
      'name' => 'facebook',
      'label' => $helper->__('Facebook'),
      ));
      $fieldset->addField('google', 'text', array(
      'name' => 'google',
      'label' => $helper->__('Google'),
      ));
      $fieldset->addField('twitter', 'text', array(
      'name' => 'twitter',
      'label' => $helper->__('Twitter'),
      ));
      $fieldset->addField('linkedin', 'text', array(
      'name' => 'linkedin',
      'label' => $helper->__('Linkedin'),
      ));
      $fieldset->addField('yelp', 'text', array(
      'name' => 'yelp',
      'label' => $helper->__('Yelp'),
      ));


      if (Mage::registry('optfirst_reviewmycompany')) {
      $form->setValues(Mage::registry('optfirst_reviewmycompany')->getData());
      }

      return parent::_prepareForm();
      }


      And following is my Saveaction method in controller:



       public function saveAction()
      {

      //$data = $this->getRequest()->getParams();
      if ( $data = $this->getRequest()->getParams() ) {

      $this->_getSession()->setFormData($data);
      $model = Mage::getModel('optfirst_reviewmycompany/review')->setData($data);
      //$model = Mage::getModel('optfirst_reviewmycompany/review');
      print_r($model->getData());

      try {
      $insertId = $model->save()->getId();
      echo "Data successfully inserted. Insert ID: ".$insertId;
      } catch (Exception $e){
      echo $e->getMessage();
      }

      return;
      }


      Also I have define the model in my configuration file like :



      <models>
      <optfirst_reviewmycompany>
      <class>OptFirst_ReviewMyCompany_Model</class>
      <resourceModel>optfirst_reviewmycompany_resource</resourceModel>
      </optfirst_reviewmycompany>
      <optfirst_reviewmycompany_resource>
      <class>OptFirst_ReviewMyCompany_Model_Resource</class>
      <entities>
      <review>
      <table>optfirst_reviewmycompany</table>
      </review>
      </entities>
      </optfirst_reviewmycompany_resource>
      </models>


      But still no luck with data save to database is there any wrong thing i am doing please check the code and try to find the mistake that where i am doing wrong..



      Thanks..










      share|improve this question
















      I have created a custom module "adminform" with some custom fields when i try to save my form data it gives the error




      "Call to a member function beginTransaction()"




      I have the following form fields:



      protected function _prepareForm()
      {
      $form = new Varien_Data_Form(array(
      'id' => 'edit_form',
      'action' => $this->getUrl('*/*/save'),
      'method' => 'post',
      ));

      $form->setUseContainer(true);
      $this->setForm($form);

      $helper = Mage::helper('optfirst_reviewmycompany');
      $fieldset = $form->addFieldset('display', array('legend' => $helper->__('Select Social Icons'),
      'class' => 'fieldset-wide'));

      $fieldset->addField('facebook', 'text', array(
      'name' => 'facebook',
      'label' => $helper->__('Facebook'),
      ));
      $fieldset->addField('google', 'text', array(
      'name' => 'google',
      'label' => $helper->__('Google'),
      ));
      $fieldset->addField('twitter', 'text', array(
      'name' => 'twitter',
      'label' => $helper->__('Twitter'),
      ));
      $fieldset->addField('linkedin', 'text', array(
      'name' => 'linkedin',
      'label' => $helper->__('Linkedin'),
      ));
      $fieldset->addField('yelp', 'text', array(
      'name' => 'yelp',
      'label' => $helper->__('Yelp'),
      ));


      if (Mage::registry('optfirst_reviewmycompany')) {
      $form->setValues(Mage::registry('optfirst_reviewmycompany')->getData());
      }

      return parent::_prepareForm();
      }


      And following is my Saveaction method in controller:



       public function saveAction()
      {

      //$data = $this->getRequest()->getParams();
      if ( $data = $this->getRequest()->getParams() ) {

      $this->_getSession()->setFormData($data);
      $model = Mage::getModel('optfirst_reviewmycompany/review')->setData($data);
      //$model = Mage::getModel('optfirst_reviewmycompany/review');
      print_r($model->getData());

      try {
      $insertId = $model->save()->getId();
      echo "Data successfully inserted. Insert ID: ".$insertId;
      } catch (Exception $e){
      echo $e->getMessage();
      }

      return;
      }


      Also I have define the model in my configuration file like :



      <models>
      <optfirst_reviewmycompany>
      <class>OptFirst_ReviewMyCompany_Model</class>
      <resourceModel>optfirst_reviewmycompany_resource</resourceModel>
      </optfirst_reviewmycompany>
      <optfirst_reviewmycompany_resource>
      <class>OptFirst_ReviewMyCompany_Model_Resource</class>
      <entities>
      <review>
      <table>optfirst_reviewmycompany</table>
      </review>
      </entities>
      </optfirst_reviewmycompany_resource>
      </models>


      But still no luck with data save to database is there any wrong thing i am doing please check the code and try to find the mistake that where i am doing wrong..



      Thanks..







      error model adminform save






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 25 '16 at 11:18









      Manashvi Birla

      6,20241841




      6,20241841










      asked Nov 25 '16 at 11:17









      QasimQasim

      12




      12





      bumped to the homepage by Community 9 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 9 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Your model should look like this.



          <models>
          <reviewmycompany>
          <class>OptFirst_ReviewMyCompany_Model</class>
          <resourceModel>reviewmycompany_resource</resourceModel>
          </reviewmycompany>
          <reviewmycompany_resource>
          <class>OptFirst_ReviewMyCompany_Model_Resource</class>
          <entities>
          <review>
          <table>optfirst_reviewmycompany</table>
          </review>
          </entities>
          </reviewmycompany_resource>
          </models>





          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "479"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f147510%2ferror-call-to-a-member-function-begintransaction%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Your model should look like this.



            <models>
            <reviewmycompany>
            <class>OptFirst_ReviewMyCompany_Model</class>
            <resourceModel>reviewmycompany_resource</resourceModel>
            </reviewmycompany>
            <reviewmycompany_resource>
            <class>OptFirst_ReviewMyCompany_Model_Resource</class>
            <entities>
            <review>
            <table>optfirst_reviewmycompany</table>
            </review>
            </entities>
            </reviewmycompany_resource>
            </models>





            share|improve this answer




























              0














              Your model should look like this.



              <models>
              <reviewmycompany>
              <class>OptFirst_ReviewMyCompany_Model</class>
              <resourceModel>reviewmycompany_resource</resourceModel>
              </reviewmycompany>
              <reviewmycompany_resource>
              <class>OptFirst_ReviewMyCompany_Model_Resource</class>
              <entities>
              <review>
              <table>optfirst_reviewmycompany</table>
              </review>
              </entities>
              </reviewmycompany_resource>
              </models>





              share|improve this answer


























                0












                0








                0







                Your model should look like this.



                <models>
                <reviewmycompany>
                <class>OptFirst_ReviewMyCompany_Model</class>
                <resourceModel>reviewmycompany_resource</resourceModel>
                </reviewmycompany>
                <reviewmycompany_resource>
                <class>OptFirst_ReviewMyCompany_Model_Resource</class>
                <entities>
                <review>
                <table>optfirst_reviewmycompany</table>
                </review>
                </entities>
                </reviewmycompany_resource>
                </models>





                share|improve this answer













                Your model should look like this.



                <models>
                <reviewmycompany>
                <class>OptFirst_ReviewMyCompany_Model</class>
                <resourceModel>reviewmycompany_resource</resourceModel>
                </reviewmycompany>
                <reviewmycompany_resource>
                <class>OptFirst_ReviewMyCompany_Model_Resource</class>
                <entities>
                <review>
                <table>optfirst_reviewmycompany</table>
                </review>
                </entities>
                </reviewmycompany_resource>
                </models>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 29 '17 at 6:33









                Aman AlamAman Alam

                943519




                943519






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Magento Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f147510%2ferror-call-to-a-member-function-begintransaction%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    What other Star Trek series did the main TNG cast show up in?

                    Berlina muro

                    Berlina aerponto