We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32963
    • 1,732 Posts
    Hi,

    Susan had pointed to some DB enhancements and a few other things. I’ve managed to pull together a few APIs based on some of the ideas put forward in the forums
      xWisdom
      www.xwisdomhtml.com
      The fear of the Lord is the beginning of wisdom:
      MODx Co-Founder - Create and do more with less.
      • 32963
      • 1,732 Posts

      What do you think about these API functions?

      $modx->db // DBAPI object
      $modx->db->config[] // config array
      $modx->db->select($fields,$table,$where,$orderby,$limit)
      $modx->db->update($fields,$table,$where)
      $modx->db->delete($table,$where)
      $modx->db->insert($fields,$table)
      $modx->db->getValue($ds)
      $modx->db->getRow($ds)
      $modx->db->getColumn($name,$ds);
      $modx->db->getXML($ds)
      $modx->db->getHTMLGrid($ds,$params)
      $modx->db->getRecordCount($ds)
      $modx->db->setConnection($host,$uid,$pwd)
      $modx->db->query($sql) // we should really use select, update, insert, etc
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 25663 MODX Staff
        • 12,272 Posts
        How do these DB functions differ from the other external DB functions? Are the APIs a clone of EZsql?
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
          • 32963
          • 1,732 Posts
          Quote from: rthrash at Jun 13, 2005, 04:01 PM

          How do these DB functions differ from the other external DB functions? Are the APIs a clone of EZsql?

          It’s kindof a mix of EzSQL and Rad’s DB API functions but it’s built just for MODx. For example, the getHTMLGrid() function will process an entire recordset and return the result as a datagrid. The getXML() function will convert an enitre recordset into an XML string

            xWisdom
            www.xwisdomhtml.com
            The fear of the Lord is the beginning of wisdom:
            MODx Co-Founder - Create and do more with less.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            A mysql_insert_id() function would come in handy. Or maybe the modx->insert() function would return the ID?
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 32963
              • 1,732 Posts
              Quote from: sottwell at Jun 14, 2005, 12:03 AM

              A mysql_insert_id() function would come in handy.? Or maybe the modx->insert() function would return the ID?

              That’s true. Maybe something like getInsertId() or maybe we could have the insert() function return the id if the everything went well otherwise it would return a FALSE. Example:

              $id = $modx->insert($_POST,"mytable");
              if($id===false){
              ? ?$modx->webAlert("Error while inserting record.");
              ? ?return;
              }
              
                xWisdom
                www.xwisdomhtml.com
                The fear of the Lord is the beginning of wisdom:
                MODx Co-Founder - Create and do more with less.