in Education by
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago. Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions. In our place we're split between using mysqli and PDO for stuff like prepared statements and transaction support. Some projects use one, some the other. There is little realistic likelihood of us ever moving to another RDBMS. I prefer PDO for the single reason that it allows named parameters for prepared statements, and as far as I am aware mysqli does not. Are there any other pros and cons to choosing one over the other as a standard as we consolidate our projects to use just one approach? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Well, you could argue with the object oriented aspect, the prepared statements, the fact that it becomes a standard, etc. But I know that most of the time, convincing somebody works better with a killer feature. So there it is: A really nice thing with PDO is you can fetch the data, injecting it automatically in an object. If you don't want to use an ORM (cause it's a just a quick script) but you do like object mapping, it's REALLY cool : class Student { public $id; public $first_name; public $last_name public function getFullName() { return $this->first_name.' '.$this->last_name } } try { $dbh = new PDO("mysql:host=$hostname;dbname=school", $username, $password) $stmt = $dbh->query("SELECT * FROM students"); /* MAGIC HAPPENS HERE */ $stmt->setFetchMode(PDO::FETCH_INTO, new Student); foreach($stmt as $student) { echo $student->getFullName().'
'; } $dbh = null; } catch(PDOException $e) { echo $e->getMessage(); }

Related questions

0 votes
    When developing distributed applications, all written in Java by the same company, would you choose Web Services ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 22, 2022 in Education by JackTerrance
0 votes
    What are pros and cons of using Laravel Framework?...
asked Sep 30, 2021 in Technology by JackTerrance
0 votes
    What are the Pros and Cons of Blazor WebAssembly?...
asked Aug 9, 2021 in Technology by JackTerrance
0 votes
    What are the Pros and Cons of Blazor Server?...
asked Aug 9, 2021 in Education by JackTerrance
0 votes
    What is Selenium? What are its pros and cons?...
asked Jul 10, 2021 in Technology by JackTerrance
0 votes
    What are the pros and cons of decision trees?...
asked Mar 11, 2021 in Technology by JackTerrance
0 votes
    What are the pros and cons of neural networks?...
asked Mar 11, 2021 in Technology by JackTerrance
0 votes
    the pros and cons of the ICT is 1 social media 2 Education 3 Both Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    I was working on a new project which has the requirement to use 7 databases, arguing that performance, ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 2, 2022 in Education by JackTerrance
0 votes
    I do know that PDO does not support multiple queries getting executed in one statement. I've been Googleing ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 1, 2022 in Education by JackTerrance
0 votes
    I am looking to get row count to check if same email is already in database or not. i have tried ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    In LISP, the function returns t if is a CONS cell and nil otherwise __________ (a) (cons ) (b) (consp ) (c) (eq ) (d) (cous = ) Please answer the above question....
asked Oct 22, 2022 in Education by JackTerrance
0 votes
    In LISP, the function returns t if is a CONS cell and nil otherwise ________ (a) (cons ) (b) (consp ) (c) (eq ) (d) (cous =) Please answer the above question....
asked Oct 9, 2022 in Education by JackTerrance
0 votes
    In LISP, the function returns t if is a CONS cell and nil otherwise __________ (a) (cons ) (b) (consp ) (c) (eq ) (d) (cous = ) Please answer the above question....
asked Oct 2, 2022 in Education by JackTerrance
0 votes
    In LISP, the function returns t if is a CONS cell and nil otherwise ________ (a) (cons ) (b) (consp ) (c) (eq ) (d) (cous =) Please answer the above question....
asked Oct 2, 2022 in Education by JackTerrance
...