Questions tagged as 'pdo'

3
answers

How to do SELECT on more than one database table?

I have two tables in the database: zip and users. Can I make a single query to get fields from the two tables? Both have idCep. I want to get the address data from the cep table and the name and user of the users table. As I'm working with ph...
asked by 25.04.2016 / 20:31
1
answer

Using $ this when it is not in object context

I'm trying to create a class in PHP that connects to the MySQL database and I'm getting the following error:    Fatal error: Using $ this when not in object context ConnectDB.class.php class ConnectDB { public $pdo; private $dri...
asked by 24.09.2018 / 22:25
3
answers

Create folder and ID simultaneously using the same id number

I need to create a folder with the same ID number as the user inserts a new article. <?php include './includes/config.php'; setMenu("Notícias"); include './includes/cabecalho.php'; checkLogin(); $erro=""; if ($_POST['salvar']) // notici...
asked by 02.01.2015 / 17:55
2
answers

MySQLi vs PDO - query execution / functions

Looking at questions here from the stack and the php.net site, I saw that the query / function runs in MySQLi uses if() to check whether it was executed or not, and PDO uses try { ... } cacth() { ... } , example connection to bank ac...
asked by 03.03.2018 / 06:25
1
answer

Am I connecting the bank with PDO in the correct way?

There are several ways to connect to the database, but I have opted for PDO. Am I doing it right? date_default_timezone_set('America/Sao_Paulo'); $pdo = new PDO('mysql:host=127.0.0.1;dbname=experiments','root'); if ($pdo) { echo "Banco d...
asked by 17.07.2014 / 02:34
2
answers

If I declare a variable in a SELECT query, is it mandatory?

My problem is that I will not always receive the variables, so I need a way that does not make them mandatory even by declaring them, for example in the query below: "SELECT * FROM clientes WHERE clientes.nome = :nome"; Var :nome...
asked by 01.07.2017 / 03:42
2
answers

Try / Catch PDOException does not work when error occurs

I created the following method to execute my querys: public function setQuery($query) { try { $stmt = self::$conn->prepare($this->limpaQuery($query)); return $stmt->execute(); } catch (PDOException $Exception)...
asked by 12.11.2017 / 01:03
2
answers

How to use PDO bindParam in the IN () of the query? [duplicate]

I have a query similar to this: $modelos = "1,2,3,4"; $sql = "Select codigo_modelo, nome From modelos Where codigo_modelo in (:codigo_modelo)" $sql->bindParam(":codigo_modelo",$modelos,PDO::PARAM_INT); //TAMBEM JA TENTEI C...
asked by 13.04.2015 / 15:44
1
answer

Error verifying user duplication

I wanted to prohibit the user from registering two identical users, type two equal emails or enrollment, but is still being registered data already exists, After I press register and send the data to the bank appears this error:    Notice: Un...
asked by 31.10.2018 / 20:50
2
answers

SQLSTATE [HY093]: Invalid parameter number problem in insert

I need to insert the following data through a form: TITLE DESCRIPTION PRICE HTML: <?php session_start(); session_destroy(); ?> <html> <head> <meta charset="UTF-8"> <title></title> &l...
asked by 17.05.2015 / 10:12