D
D
Deman12020-04-22 01:37:55
PHP
Deman1, 2020-04-22 01:37:55

How to work with pdo?

I want to switch to PDO with mysqli and there was a moment that I figured out for a long time what and how PDO is and it was so that PDO showed data from the mysql database when a connection failed, how can I avoid this?
mysql is not available from time to time and the connection is lost for a short time, and you don’t really want to burn the data, so how to deal with it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FanatPHP, 2020-04-22
@Deman1

Well, guys, why do you write one question in the title, which you immediately think about - but he googled in general, well, at least his question title ?, but in the text - a completely different one, which has nothing to do with the title at all?
In order for pdo not to burn the password in the call stack, you need to do two things:
1. You need to carefully catch the connection error, and immediately throw a new exception with the error text . Thus, we will not lose the error, but we will remove the stack from it.
2. If the connection is made inside the function, then the connection parameters must not be passed directly in the function parameters, but either as an array, or not passed at all, but received inside the function
So that PHP does not burn error text on the screen- about what you really have a question about - you need to tell PHP so that the text of errors does not burn on the screen. For this, there is a special setting for you about it in the comments.
As you can see, all the problems - from the inability to formulate questions. Because if the question is properly formulated, then the answer immediately becomes obvious.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question