Questions tagged as 'pdo'

2
answers

SQL result has field and index

I have a function in PHP to automate the queries I make: //arquivo funcao.php function executaSql($sql, $param=array()){ try { include "config.php"; $q = $conn->prepare($sql); $q->execute($param); $res...
asked by 28.07.2016 / 15:05
2
answers

Adding numbers from a MySQL column using PHP

I have several results in the MySQL database, I want to get the results and add all the numbers of a column in PHP. How do I?     
asked by 20.06.2015 / 19:35
3
answers

Check if $ _GET value is 1 or 2 and execute SQL UPDATE

I have $_GET['id'] and I need to check if the value it takes from url index.php?id= is 1 or 2 , and if none of the alternatives performs a die(); , if it is 1 or 2 it assigns $var = $_GET['id']; and with a i...
asked by 10.06.2014 / 18:46
2
answers

Query returns empty using PHP with PDO and MS SQLServer

I am migrating a system made in ASP to PHP. However, I'm having trouble making a query using the PDO: Search.php class Busca extends Conexao { private $termo; public function setTermo($termo) { $this->termo = $termo; } pu...
asked by 11.11.2015 / 19:15
2
answers

PDO security question PHP

I would like to know the difference in security level of the two code snippets below: // TRECHO 1 <?php $calories = 150; $colour = 'red'; $sth = $dbh->prepare('SELECT name, colour, calories FROM fruit WHERE calories < ? AND co...
asked by 13.11.2015 / 15:18
2
answers

How to add everything in MYSQL

How do I add all of a table in MySQL for example .. I have the table tb_comment , so I want to add in each post(id_mark) the amount of rate that will have the total. For example, id_user 20 has the rate of 4 in id_...
asked by 11.12.2015 / 23:15
1
answer

Problem with bindParam - PHP

I'm having problems with bindParam, could anyone help me? I have a code for user registration in the bank ... <?php require_once 'init.php'; // Pega os dados do formulario $nome = isset($_POST['nome']) ? $_POST['nome'] : null; $nascime...
asked by 28.12.2016 / 01:18
1
answer

How to close a connection to the database using PDO?

I'm new to the PHP development area and my app uses a method to open a connection to the database in MySQL , I'm looking to update and display the records. I need to use some method to close the connection, type: function close() ? p...
asked by 31.08.2015 / 15:40
2
answers

Counting strings reached PDO

I'm doing a query and need to count the number of rows returned, I'm not usually accustomed to doing this in PDO, follow my code below. $sqlCODCEL = $conn->prepare("SELECT * FROM tbl_CELULAS WHERE TXT_CODIG_SECUR = :codCEL"); $sqlCODCEL->...
asked by 24.08.2015 / 13:47
2
answers

select pdo with oo

I have this class that manages the database: <?php abstract class database{ /*Método construtor do banco de dados*/ private function __construct(){} /*Evita que a classe seja clonada*/ private function __clone(){} /*Mé...
asked by 09.11.2015 / 13:18