Questions tagged as 'pdo'

1
answer

PHP PDO transaction with multiple objects

The idea would be this: I have 3 classes, one for connection to the bank, another for Users and another for Product. The User class with the database tb_usuarios . The Product class with the database tb_produtos . I make...
asked by 18.04.2018 / 13:15
2
answers

Count Database result [closed]

Hello. Good night. I have a question I want to sum all the values of the field valor_reais of my table forexampleid1=150id2=100id3=100Iwanttheobviousresult,350I'vetriedsomethinglike:$buscar=$pdo->prepare("SELECT * FROM tabela...
asked by 08.04.2018 / 22:47
3
answers

How to get the number of rows from a SELECT statement in PDO? [closed]

How do I know the number of records that returned me from a SELECT statement? I tried to use rowCount() but this did not work in my code, I just want it to return the amount just that. $contador = $this->con->conectar()->prepar...
asked by 10.12.2017 / 17:47
1
answer

Does anyone know where the error is in this code?

The error that is generated is as follows:    Notice: Only variables should be passed by reference in Can you tell me how to solve it? According to the error, it is in this part: $extensoes_aceitas = array('bmp' ,'png', 'svg', 'jpeg', '...
asked by 05.09.2018 / 00:51
1
answer

Insert with Foreign Key (user + address (FK)) PHP (PDO) + MySQL

Good afternoon, guys. I have a small question: When registering a client (with an address field (fk)) is the correct way something like this, or does it have a better way? INSERT INTO endereco(logradouro, numero, bairro, cidade) VALUES (:log...
asked by 30.11.2017 / 20:07
2
answers

List DB data using echo (PDO)

Hello, I have this code: <<?php include("conexao.php"); $pdo = conectar(); $buscarusuario = $pdo->prepare("SELECT * FROM tab_clientes WHERE ID=:id"); $buscarusuario->bindValue(":id",2,PDO::PARAM_INT); $buscarusuario->execute()...
asked by 13.12.2017 / 23:34
1
answer

Save array to different columns with fputcsv

I'm trying to output some data from DB to csv with the following code: while($linha=$buscar->fetch(PDO::FETCH_ASSOC)){ fputcsv($out, $linha); } fclose( $out ); } which returns the entire contents of the array in a single column. Ho...
asked by 09.10.2017 / 15:39
1
answer

How to execute the same query for different "ids"

I have an array with the following IDs: Array ( [0] => 2 ) Array ( [0] => 3 ) Array ( [0] => 5 ) The query should return all the values found for these IDs, so what will be the assembly of query [using PDO]?     
asked by 25.08.2017 / 01:20
2
answers

Grouping a set of measures in PHP

I have a problem to join a set of values. I have a wood marking system. I feed the database with the length x width of the wood Id, order_id, length, width, date Registros: 1, 3, 320, 20, 05-25-2017 2, 3, 320, 25, 05-25-2017 3, 3, 310...
asked by 30.05.2017 / 22:18
1
answer

Error doing PHP delete using PDO class and object orientation

I am doing a delete on my form manut_usuario , below is my method to delete that is in class usuario.class.php ; public function DelUsu($id){ try{ $delUsu = "DELETE FROM usuario WHERE idu_usujport = :id ";...
asked by 23.06.2017 / 02:34