Jump to content
Larry Ullman's Book Forums

Recommended Posts

Hi Larry

 

I found your book in my pursue for learning more about PHP. I learn procedural programming with PHP and PDO for Database related operations from the first book I bought. With your book I see you are using mysqli and you cover PDO in chapter 8. I know that:

 

1. Mysqli provides database specific functions.

2. PDO is an abstraction layer, which means you can easily use your database functions no matter which database you are using.

3. If you go to the OOP rute then PDO is the standard for database functions.

 

I know that there are more things, but to make a long story short, for a beginner...who's making his way into PHP and as a starting point with 5.3 flavor and up .

 

* Should I stick to PDO?

* Is mandatory to learn mysqli too?

 

I wish you would have used PDO from a very begining in your book. Still have a lot to learn and assimilate. Apart from that...thanks and you got a new reader :)

 

Víctor

Link to comment
Share on other sites

Hello, i am not Larry, but i will answer a little.

 

If you are using PDO it would depend on what type of application you wanted to build, most of the online software available online is using MySql as its base. Mysqli also has its own class which you can extend and override its functions if you wish.

 

If you are new to PHP you should begin with MySQL because being able to use PDO to select any type of database driver like Oracle or MySQL etc is implementing an Object-Orientated design pattern called the "Factory Pattern" When you begin learning PHP you will code in the procedural style where as Object-Orientated is Advanced PHP. That's why Larry's books are starting of with MySQL and because its the most widely used database software it being free.

Link to comment
Share on other sites

Thanks Edward, I get the book covering that part , so I'll be learning that part too, I knew there was a good reason for that, and seems I was missing more than just lil part lol.

Sometimes I feel there's no enough time to study all I have to :wacko: , anyway...I'm going step by step.

Link to comment
Share on other sites

— PDO is nice, but what are your needs? If you want to release a new open source blog system, then PDO would be that way to go. If you are just developing a personal, database driven to-do list, then you wouldn't necessarily need PDO's abstractions. It all boils down to your indented usage.

— Not mandatory by any means. However, if you plan on using a MySQL database, then by all means use PHP's MySQLi extension if PDO is not really needed. Let's say MySQLi is mandatory when dealing with a MySQL database, and you should no longer use MySQL functions in PHP.

 

Note that MySQLi is also written Object-Oriented, and all MySQLi functions comes with both procedural and object-oriented examples.

Link to comment
Share on other sites

Hi Antonio, my concern is to learn how to program in PHP the right way, there are tons of books out there most of them are out-dated, and as a beginner you have to deal with all of these and even worst, those tuts sites where they should teach good coding practices and good samples most of the time have errors and aren't near good.

I still have a hope since I found Larry's books :), I'll be studying hard...so some day in a near future I'll be in the position of being able to choose "this way" or the "the other" according to the application I would build.

 

Thanks!

Link to comment
Share on other sites

I would get out of the thinking that there is one "right way". You ask 10 programmers how to do something and you'll get 12 answers. For most things, if it works, it's okay, and differences are minor (except when it comes to security). You should give a lot of credence to the things that feel right to you, too.

Link to comment
Share on other sites

Don't focus too much on micro optimization or best practices. Writing secure code is the most important aspect in my book. Then comes maintainability and easy to read code. You should focus on developing classes that don't do to much, are not tightly coupled and are easy configurable. What I mean by this is that you should be able to create a library and use parts of that whenever you need. (You do this just because you don't want to re-invent the wheel every time) The basics are the most important part of object-oriented design.

 

It is absolutely a good idea to experiment with ideas on the side, though. I like to test out different things just because I'm curious. My suggestion would just be to experiment, ask questions and make sure to have fun. There's seldom a "the correct and absolutely best way" for things.

Link to comment
Share on other sites

Larry and Antonio, thanks for the advice, much appreciated. I guess I will develop my "coding style" with time, knowlege and practice. Yes, Antonio, lots of fun and hours haha, hopefully I got a new "all-terrain" keyboard.

 

Now I realize that the first book I read was very basic, the next books I read just added some confuse to the mix :wacko: and a bit of frustration. And because of that, I started to look some new material to learn from, and I found PHP Advanced and Object-Oriented Programming in Amazon. It's really like fresh air, but for the sake of my mental health, I'm going through PHP and MySQL for Dynamic Web Sites, my ideas are getting align, and now everything looks clear.

 

Just to say thanks Larry!

Link to comment
Share on other sites

 Share

×
×
  • Create New...