We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3121
    • 12 Posts

    I was wondering about the lack of a "replace" function in the DBAPI.
    is it intentional ?

    Do u think we should add it ?


      • 32963
      • 1,732 Posts
      Quote from: BenO at Jan 06, 2006, 05:22 PM


      I was wondering about the lack of a "replace" function in the DBAPI.
      is it intentional ?

      Do u think we should add it ?


      You sure can
        xWisdom
        www.xwisdomhtml.com
        The fear of the Lord is the beginning of wisdom:
        MODx Co-Founder - Create and do more with less.
        • 32241
        • 1,495 Posts
        Will you add it to the feature section, so that it will be added for future release? Sorry core programmer, hope I’m not giving too much trouble to you all.
          Wendy Novianto
          [font=Verdana]PT DJAMOER Technology Media
          [font=Verdana]Xituz Media
          • 19726
          • 239 Posts
          Quote from: BenO at Jan 06, 2006, 05:22 PM
          I was wondering about the lack of a "replace" function in the DBAPI.

          is it intentional ?
          I a bit curious about this "replace" function. What would it do?
            • 32241
            • 1,495 Posts
            Check this document
            http://dev.mysql.com/doc/refman/5.0/en/replace.html

            I believe we can use INSERT ON DUPLICATE KEY UPDATE syntax instead of REPLACE, to follow SQL standard, which later can be easily ported to other DB.

            It’s not a major thing though, because not much applicatio will use this functionality, but it’s not a bad idea of adding a few lines of code to make the DB API as complete as possible. smiley
              Wendy Novianto
              [font=Verdana]PT DJAMOER Technology Media
              [font=Verdana]Xituz Media
            • My only concern with this wendy is, that the DBAPI’s purpose is to help abstract the DB layer, and REPLACE statements are extensions to the SQL standard and not always supported. And the goal of abstraction is to hide the discrepencies between different target DB platforms.

              Now, using these REPLACE statements is fine if you are married to a particular platform and are designing a system for pure optimized speed, though that can easily be done by authoring the REPLACE SQL and using the existing query() function to execute it. But adding this does not provide any real benefit for future portability or features IMO, as I would expect to see less and less contact with SQL at all in the system moving forward.

              However, if others feel strongly about having this function, I certainly won’t oppose the addition for now.
                • 32241
                • 1,495 Posts
                Ehmm...

                Not in my case though. I second your opinion about the DB abstraction.

                I try to look into the DB API, and they have no INSERT function. Do you think it’s important to be added?

                * Escape
                * Query
                * Select
                * Delete
                * Update

                We need select, delete, update, and insert for database processing. I do believe insert is being supported on major sql syntax, even though I’m not to for sure the standard sql formating for insert. It’s not something necessary, because we can achieve that using query function, but it would be nice to be added later.

                I believe, when we come to upgrading MODx to support DB abstraction, this API will be improved.

                Another thing though, what do guys think about DB abstraction? Sometimes it makes thing a lot slower, because it’s adding another layer into the system? There has been a lot of debate about this, and I’m kind of confuse on which side should I be on. Any suggestion to my question will be great.
                  Wendy Novianto
                  [font=Verdana]PT DJAMOER Technology Media
                  [font=Verdana]Xituz Media
                • There is definitely an insert() function in the DBAPI. huh

                  And once abstracted, you will simply get, create, save, and delete objects using methods. No more SQL period. That’s the point. So in essence the DBAPI will only be kept around in order to support legacy code that makes calls directly to the DB.

                  And yes, DB abstraction does usually mean a small decrease in performance in exchange for increased code maintainability, DB portability, modularity, and never having to write another SQL query again. Depends on what you need/want. The alternative to abstraction is isolating the SQL and simply reimplementing it for each platform. This can be optimized further than a system built on a DB abstraction layer, but would of course, require developers to be able to maintain code for every target platform.
                    • 32241
                    • 1,495 Posts
                    Thanks for the reply Jason.

                    I didn’t look into the code, and the documentation stated only this API
                    * Escape
                    * Query
                    * Select
                    * Delete
                    * Update

                    Next time I will double check everything, before posting.
                    As for the advice, it’s really a great deal of information to me. As I understand, MODx will move to DB Abastraction phase, right, instead of isolating SQL for each db platform? I;m just thinking of a performance wise while using db abstraction. Right now MODx depends widely on querying database back and forth, even though there has been an implementation of db caching mechanism, but it’s still depend widely on database.

                    So do you think running a stress test to MODx core code will be a better idea for the future milestone? Right now I can see the growth of MODx to be extended into a specific website application that are running not only as CMS system, but it’s more into a simple web application framework. So with that regards, having a stress test to test the core code will be awesome. I never try this, but I will try to do more research on this, and hopefully I can get this done soon.

                    Thanks
                      Wendy Novianto
                      [font=Verdana]PT DJAMOER Technology Media
                      [font=Verdana]Xituz Media