Questions tagged as 'pdo'

3
answers

Get last auto increment PDO key

I have a problem with my system that looks like this, try { $sql = "SELECT Nid+1 AS Nid FROM noticias ORDER BY Nid DESC LIMIT 1"; $stmt = $DB->prepare($sql); $stmt->bindValue(":Nid", intval($_GET["Nid"])); $stmt->execute(); $results...
asked by 26.10.2015 / 17:21
2
answers

What is the difference of bindValue for an array executed directly in $ pdo-execute ()

I currently use a schedule like this <?php $array = array('nome'=>'Alisson', 'idade'=>20); $query = $conn->prepare("INSERT INTO table (nome,idade) VALUES (:nome, :idade)"); $query->execute($array); ?> What's the differe...
asked by 18.12.2015 / 02:52
1
answer

Error connecting database with PDO

I have an OOP code in PHP, when I try to connect to the DB, the following error appears:    Notice: Undefined variable: operator in C: \ xampp \ htdocs \ StudentCount \ app.ado \ TCriteria.class.php on line 16       Notice: Undefined variabl...
asked by 05.09.2015 / 18:16
2
answers

How to make a SQL query that returns an object instead of an array?

There is not much to talk about. What I need is to know how to do a query that returns an object to me instead of an array in the format: $eventos = [ new Evento(1, new \DateTime('2015-01-26'), 'Titulo #1'), new Evento(2, new \DateTime...
asked by 21.09.2015 / 16:26
2
answers

Generic Crud with PDO

The connection part is ready: <?php /* * O padrão Singleton */ abstract class Conexao { const USER = "root"; const PASS = ""; private static $instance = null; private static function conectar() { try { ##Tenta conectar ao banco...
asked by 02.09.2014 / 15:21
2
answers

Insert multiple with PDO php and MySql

My situation, A POST form with a text input and two input radios. Inputs are named respectively nome[0] and tipo[0] . When someone adds more fields to the form, I put .attr to get nome[1] and tipo[1]...
asked by 29.01.2018 / 02:27
1
answer

Select with PDO and SQL barring HTML

I'm trying to make a Select with PDO and MYSQL, but when I put the php code doing this query in the middle of my html it does not allow the execution of the rest of the page. follow the code snippet: <select class="emselect"> &l...
asked by 19.10.2017 / 15:16
1
answer

Is my database access role secure?

I have a file that has CRUD operations with PDO and MySQL, my question is if I leave my functions as the function below: function delete($tabela, $id) { global $con; $sql = "DELETE FROM " . $tabela . " WHERE id=:id"; if(is_arra...
asked by 25.09.2017 / 00:36
2
answers

Distinguish equal fields in a SELECT with LEFT JOIN

In SELECT done in two tables with similar fields I'd like to distinguish the field from each table when it shows the results. For example: $sql = BD::conn()->prepare("SELECT a.*, b.* FROM tabela_a a...
asked by 24.02.2017 / 14:12
2
answers

How to request day data in SQL with Unix Time Stamp (PHP)

Hi, I'm having one with a question here, I'm creating a code to get how many users logged into my site today, but I saved the last date it logged with Unix Time Stamp. I'm just getting the users who logged in the last 24 hours, but what I wan...
asked by 07.01.2018 / 17:17