What is the difference between JSON and PHP Serialize

Поделиться
HTML-код
  • Опубликовано: 23 ноя 2024

Комментарии • 25

  • @jherbison
    @jherbison  2 года назад +6

    Let me know if I need to expand on this... I wanted to briefly touch on the differences.

    • @anirudhachakrabarty2050
      @anirudhachakrabarty2050 2 года назад

      Yes please... I have come up with a scenario.. Where I have a datatable where I fetch filtered data from orders. And I want to select some rows for refund. Like from that datatable I want to select some rows as refund request. And Want to put an extra user input column where the executive can put from where that request came from like call or email just a input text. I wnt those checkbox selected rows data to save in another table named refund request. I am able to select that and get the id but can't able to get the values of all the column values for that selected rows.. I used php jQuery Ajax... How can I send those entire row values? Can you please help?

  • @srdjagunjic
    @srdjagunjic 2 года назад +3

    Awesome video

  • @ЗаблокироватьГлобальныйПидарас

    Great! I need tutorials wp development non-standart themes and plugins! It's needed all over the world🌏 developers

  • @кремневесты-ю6ц
    @кремневесты-ю6ц 2 года назад +2

    LOVE ❤ This tutor! 🌟

  • @dashingpix
    @dashingpix 2 года назад +3

    Another great one, thanks bro :)
    As you touch on JSON, now why cant we explore @wordpress/scripts, and how we can utilize/use React on WordPress in the Wordpress way with WP REST API. Just a suggestion, if possible :)

    • @jherbison
      @jherbison  2 года назад +2

      Awesome.. Thank you for watching and commenting.. I will add that to the list of videos to make.

  • @aogunnaike
    @aogunnaike 2 года назад +2

    Awesome content, when do you decide as a developer to build a feature as a plugin or with the custom theme? Thanks

    • @jherbison
      @jherbison  2 года назад +1

      Great question.. Thank you. Typically, we build all customization in plugins. That way if they decide to change the look, we don't have to bring over all the customization to a new theme.. The plugins should always be able to work on any site. Thank you for watching and commenting..

    • @ЗаблокироватьГлобальныйПидарас
      @ЗаблокироватьГлобальныйПидарас 2 года назад +1

      @@jherbison Interesting!👍

    • @jherbison
      @jherbison  2 года назад +1

      Thank you.

  • @UrielSoto
    @UrielSoto 2 года назад

    Thanks for the video!

  • @V3ritas1989
    @V3ritas1989 2 года назад +1

    Greate timing, I have a follow up. So today I stumbled uppon people having placed serialized data into the DB. Which is totally annoying for what I want to do because now I cannot just write a bigger mysql query to pull the data with calculations and grouped in the format how I need it. But I will probably need to write at least 300 lines in php instead of simple 30 lines in sql. Which would also be way more readable than doing all these calculations during loops in php. Specifically, this is about delivery costs for purchase orders for each supplier by country, that have been entered serialized in the supplier table. So my question. Should people be doing this? Cause now I can't use "group by" and probably need to loop through thousend of orders every time I want to do the analysis. Which takes way longer in PhP than in the 3 second sql query... So, where should people use serialized data and where shouldn't they?

    • @jherbison
      @jherbison  2 года назад

      Thank you for the question. So it is great to have the data serialized, but yes it can make it difficult or slow to process a database query. If you have access to the code when the order is placed, you could separate those details and put them in as separate data. If not, but you have access to the database: You could run a script (maybe a cron) that would separate out the data you need and put that into a separate table even like as a taxonomy table. New table could be column1:order_id and column2:country. Make sure both columns are indexed (order_id being unique) and then you would be able to quickly do a query when you need to based on country. You could also do that for any searchable data.. Maybe the second column is country, maybe it is "value", but then you would need to make sure that order_id isn't unique, but maybe add an ID that is unique, as it won't let you put in two rows with the same order_id. Hope that isn't confusing and helps!

  • @amirgohary1999
    @amirgohary1999 Год назад

    Hi Joshua
    Thanks for the great video
    Actually I am willing to send array from $_POST form to mysql.
    Just I need to know the best way to send this array as serialized or JSON
    I see someone here, is mentioned that "Serialization in PHP can be corrupted easily if you save it to database "

  • @wiktorliszkiewicz354
    @wiktorliszkiewicz354 2 года назад

    Serialization in PHP can be corrupted easily if you save it to database and string replace without changing serialization variable length. No such issue with JSON. And if you need to encode user data as JSON you might simply escape data before pushing it to JSON. This is the main reason why you can not simple search and replace MySQL dump SQL file while migrating to another domain, because it will brake serialized data if such is present.

  • @crowbr
    @crowbr Год назад

    Have some way in javascript to serialize like a PHP, i need pass a array to api and this request its a PHP serialize format not JSON.stringfy :z

  • @philip9677
    @philip9677 2 года назад +1

    When should we use Json and when should we use serialize

    • @jherbison
      @jherbison  2 года назад +1

      Always use serialize if saving to the database or sending to another php application. Use json if you don’t know what the other application format will be or if you know for sure it isn’t php.

    • @philip9677
      @philip9677 2 года назад +1

      @@jherbison Thanks Josh, am actually just starting to learn php, the tutorials are awesome

    • @jherbison
      @jherbison  2 года назад

      @@philip9677 Thank you.. That is great that you are starting to learn php.