Intro to Doctrine PHP - DataBase Abstraction Layer - Query Builder - Full PHP 8 Tutorial

Поделиться
HTML-код
  • Опубликовано: 14 мар 2022
  • In this lesson, we learn about Doctrine Database Abstraction Layer library. We learn how to use query builder, how to inspect database schema & so on.
    SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL
    👍 Smash the like button
    🤝 Subscribe to the channel & turn the notifications on
    💬 Post comments, any feedback is greatly appreciated
    ⭐ Become a Patreon: / programwithgio
    THANK YOU!
    🛠️ TOOLS & SERVICES I USE
    Digital Ocean Hosting - Get 100$ credit - m.do.co/c/38b935ad74e5
    Domains on Namecheap - namecheap.pxf.io/rnRjdQ
    Envato Elements - 1.envato.market/c/2937311/298...
    Adobe Photoshop & Premiere - clk.tradedoubler.com/click?p=...
    COURSE PLAYLIST
    • Learn PHP The Right Wa...
    RESOURCES
    Source Repo - github.com/ggelashvili/learnp...
    Doctrine DBAL - www.doctrine-project.org/proj...
    ** Affiliate Disclaimer: Some of the above links may be affiliate links, which may generate me a sales commission at no additional cost to you.

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

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

    Thanks for the most awaited series.

  • @Zubbee
    @Zubbee Год назад +1

    Learning new things even more. Thanks Gio. The refactoring is a intriguing. And the videos have become faster which is great cause I'm sure it lets you squeeze in more stuff and then we can slow it down or taking it easy so we can get all the stuff you squeezed in out. I recommended the series directly to someone today and I think he has started from the first video already. Thanks again Gio

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

    You never fail 😄, thank you.

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

    Great video as always.

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

    The great Gio thanks alot ❤️

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

    That's amazing, thank you

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

    Great! Many thanks!

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

    wow great gio

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

    nice tutorial

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

    It was good tut... sure enough 😉

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

    Can you make some videos on SOLID principles as well? Your content will be the best one in the entire internet.

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

      Thank you. Yes might do that in separate series

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

    Thanks for nice tutorial! Just one off topic question: how did you align "connection params"? Is it any default phpstorm shortcut or need to setup phpstorm to do so?

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

      ctrl + alt + l if it doesnt work then you can adjust the alignment from the phpstorm settings for PHP

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

    Thanks a lot for that video!! .. And so on! lol

  • @omaryahia
    @omaryahia 3 месяца назад

    I can't be a perfectionist
    with some topics like doctrine
    I don't think I need to go into details
    so
    I make a trade off
    I get some value by watching and taking general notes
    I miss a lot of value by not doing hands-on codes
    but I accept this risk/loss
    now, I don't need to slow down
    I can continue in the playlist as I am
    the costly decision of getting in-depth + asking questions + hands-on
    will be saved for topics I feel more relatable to my career in the short term
    just an approach I am using
    to manage the gains of my study streak following a curriculum/roadmap
    I hope I do well

    • @ProgramWithGio
      @ProgramWithGio  3 месяца назад +1

      Thats fine, you might like the active record pattern ORM like Eloquent from Laravel

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

    As always absolutely Love your content and way to teaching ♥ ♥ ♥ ♥ ♥ Can you tell me which package you use to get array key and values on same level to each other like on 3:33? Thank you once again ♥

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

      Thank you. It's a setting in my IDE under Code Style (PhpStorm).

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

      @@ProgramWithGio what extra setting parameter you use, can you tell, I also want that one 😊

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

      Code Style -> PHP -> Wrapping and Braces -> Align consecutive assignments
      Code Style -> PHP -> Wrapping and Braces -> Align constants
      Code Style -> PHP -> Wrapping and Braces -> Array Initializer (checked all 4)
      I think that's all, there might be couple more but it should be all under Wrapping and Braces section so play around with those settings.

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

      Appreciated! Thank you so much 😊 ♥ ♥ ♥ ♥ ♥

  • @user-gv8xg5bh1e
    @user-gv8xg5bh1e 3 месяца назад

    Hello, thank you for all these videos. Please tell me how autoload Dotenv\Dotenv. I can do it 'composer require symfony/dotenv' ?

    • @ProgramWithGio
      @ProgramWithGio  2 месяца назад

      We covered that in second section, search the playlist, you will find it

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

    Hello Gio, I hope you're having a good day!
    I have a question right here : 09:26
    *executeQuery()* second parameter is an array of arrays right ? because it throws an error when I take off the brackets of $ids ( related to the vendor doctrine DBAL classes )

    • @ProgramWithGio
      @ProgramWithGio  Год назад +1

      Hello. In this case yes because we are using where IN().

    • @sefyankehail7801
      @sefyankehail7801 Год назад +1

      @@ProgramWithGio Got it, thank you!

  • @truthteachers
    @truthteachers Год назад +2

    For info: at timestamp 9:50, the type argument "\Doctrine\DBAL\Connection::PARAM_INT_ARRAY" has been deprecated and we need to use "\Doctrine\DBAL\ArrayParameterType::INTEGER".

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

      Yup, thank you for the note. We use older version in this recording but later videos we have up to date version.

  • @expresscoding3525
    @expresscoding3525 7 месяцев назад

    Hello sir, at 9:50, I see [\Doctrine\DBAL\Connection::PARAM_INT_ARRAY] this part is deprecated, what to do?

    • @ProgramWithGio
      @ProgramWithGio  6 месяцев назад

      Use \Doctrine\DBAL\ArrayParameterType::INTEGER

  • @mehdi-vl5nn
    @mehdi-vl5nn Год назад

    so an Orm plays as data access and business layer at the same time in a Laravel app for instance?

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

    Which exception does the \Doctrine\DBAL\DriverManager::getConnection()
    throws

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

      You can inspect th get connection method and see. I don't remember off the top of my head

  • @user-gv8xg5bh1e
    @user-gv8xg5bh1e 3 месяца назад

    How to create table with doctrine dbal dynamically ?

    • @ProgramWithGio
      @ProgramWithGio  2 месяца назад

      You would typically use migrations, what do you mean by dynamically & what would be the use case?

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

    Hi Gio, please 2 quick questions.
    1. "driver" => 'pdo_mysql' ?? $_ENV['DB_DRIVER']. Without inverting this statement, I get doctrine does not support mysql
    driver that we had been using despite having pdo_mysql driver installed. Am using Fedora 36.
    2. $stmt = $conn->prepare('SELECT * FROM invoices WHERE id = ?');
    This line gives the error message below.
    An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; heck the manual that corresponds to your MySQL server version for the right syntax to use near '?' at line 1.
    Still trying to figure out the reason and solution. Any assistance will be highly appreciated.

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

      Hi, was able to resolve the 2nd part of the question. Binding the position or named parameter and calling the executeQuery() without parameter resolved the issue.
      Using named parameter:
      $stmt = $conn->prepare('SELECT * FROM invoices WHERE id = :id');
      $stmt->bindValue('id', 100);
      $result = $stmt->executeQuery();
      using position parameter:
      $stmt = $conn->prepare('SELECT * FROM invoices WHERE id = ?');
      $stmt->bindValue(1, 100);
      $result = $stmt->executeQuery();
      The sql error has to dp with mysql keywords or reserved words. But am still unable to figure it out as the id
      isn't a keyword or reserved word. Will keep digging.

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

      Hey, glad you figured it out. The query looks correct, you do need to bind the values though which you did seems like, if you are still getting an error send me a DM on twitter & send me the screenshot of your actual code and I can help troubleshoot.
      About your first question, pdo_mysql is the correct driver for pdo mysql. You can also send me screenshot of your code on Twitter & I can take a look.

    • @themaridv2000
      @themaridv2000 6 месяцев назад

      ​@@ProgramWithGioif I use pdo_mysql, the rest of conections stop working because we have been using just mysql as the DB_DRUVER. I don't know what to do, should i create a new db service and create another db conection that uses pdo_mysql?

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

    Which sql driver is better to use.

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

      Whichever you like. I use mysql

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

      @@ProgramWithGio well the doctrine does not support mysql does it have any reason for that

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

      It does, we use mysql in this lesson. Check the documentation or the video again (3:21), it uses pdo_mysql. Doctrine supports PDO driver so whatever drivers PDO supports can be used with doctrine.

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

    Its odd, in the documentation i only get "listTables()" and not "listTableNames()"'. When i look at the definition for ""listTables()"' i able to find "listTableNames". I may be wrong, as I see the documentation is very summary level. Is there anywhere we could get a list of methods for DBAL?

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

      listTableNames is available on the schema manager, maybe documentation is missing it but you should be able to open up AbstractSchemaManager and see both listTables & listTableNames there

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

      @@ProgramWithGio Thank you for the reply. Only worrying thing is that we may not know all methods to make best use of the library/extension.

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

      @@truthteachers you don't need to know. When you have a need for a specific method then you start searching for it. I do agree that Doctrine could use a better documentation. I've had to dig into the source many times

  • @po3881
    @po3881 7 месяцев назад

    In these later videos I find the moving blue background and animations distracting from the content. Just trying to help by mentioning.

  • @Netz0
    @Netz0 8 месяцев назад +1

    Don't use ORM's, just learn SQL, you will thank me later once your application suffers from badly joined queries as it keeps growing.

    • @ProgramWithGio
      @ProgramWithGio  8 месяцев назад +3

      I've been using ORMs for a long time along with raw SQL without any problems. I do agree that knowing SQL is essential without it you are just waiting for problems to happen, but if you know SQL and know how ORM works you will be able to build efficient queries

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

    Thank you very much for this video, If you can share with us the main class for \App\Enums\InvoiceStatus::tryFrom() that you are calling on ruclips.net/video/bfTIVQvS5JI/видео.html. I was having something like this before but your functions are very elegant and readable

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

      There is a link to the repo in the description that contains the code. tryFrom is part of the enums feature, you check the lesson about enums where we discuss that.

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

      @@ProgramWithGio Thanks a alot