Most voted "pdo" questions
The PHP Data Objects (PDO) extension defines an interface for accessing PHP databases. Each database driver that implements a PDO interface can expose database-specific features as normal extension functions.
Learn more…927 questions
Sort by count of
-
1
votes1
answer133
viewsDoctrine DBAL bank operations DB
To make bank operations and better use(or which to use): Data manipulation Query-Builder To work with data manipulation ? and how I would do to make bank operations will go with it for example:…
-
1
votes1
answer198
viewsDoubt about the Doctrine dbal project structure
I read the Documentation the only thing I didn’t understand was what his structure is like. Explain: My file composer.json at the root of the project { "require": { "doctrine/dbal": "2.4.*" } } When…
-
1
votes2
answers226
viewsIs using Prepared statements and bound values enough to avoid SQL Injection with PDO?
I wonder if it’s safe to search the database that way: $c = $conn->prepare("SELECT * FROM tb WHERE coisa = :post"); $c->bindValue(':post', $_POST['login']); $c->execute();…
-
1
votes1
answer255
viewsEquivalent of mysql_result in PDO
I’m trying to move from mysql to Pdo but do not understand how to step that mysql_result to Pdo, I appreciate any help made available $limite = 10; $SQL_COUNT = mysql_query("SElECT COUNT('id') FROM…
-
1
votes2
answers148
viewsHow to insert the ID in the database since it is the first field of the table?
I have auto increment ID and am having error counting columns with this code. How can I enter the ID together? #SQL Execute $uir = $pdo->prepare("INSERT INTO visitados VALUES (:IMO_CODIGO,…
-
1
votes1
answer681
viewsPDO Insert does not work
Before you ask me the question, I have consulted other topics here in the OR and found no solution. I’m trying to make a simple Insert and as soon as I run the whole script just doesn’t happen, the…
-
1
votes1
answer43
viewsHow to insert into bank with Prepared statements? Problem with ID
I’m having trouble counting columns because I don’t know how to input the data by PDO when you have a id AUTO_INCREMENT that comes before the variable nome. I don’t know exactly how to insert the id…
-
1
votes1
answer664
viewsHow to call PDO in separate system file?
I have a programming problem in which I put my PDO type connection in the header and I need that $pdo be called in any other system file. Example: header.php <?php require("configs/conexao.php");…
-
1
votes3
answers2472
viewsGenerate single random value with php
I need to generate a random value with letters and numbers in PHP, always starting with the letter A and having numbers and letters mixed with the value. Refers to the "control code" field contained…
-
1
votes1
answer46
viewsInsertion with non-standard characters
When I enter into Mysql database with PHP and PDO are entering strange and disordered characters, which may be wrong? Here is a picture of a bank table: My page has the parameter: <meta…
-
1
votes3
answers776
viewsPDO paging - Problems with prepare(); select();
Hello, I’m having trouble printing table data. Updating: I inserted the following lines in the file php connection.: public function select(){ $sth = $this->prepare("SELECT id_prato, titulo,…
-
1
votes2
answers201
viewsI have doubts whether this would be the right way to make a connection using the PDO class
I’m wondering if this is really the right way to make a connection between php and mysql with the PDO class. The question is as follows: Each time I have a file that uses this connection it will…
-
1
votes1
answer1373
viewsEncrypt password and log in PHP and PDO
File login.php <?php session_start(); require_once '../includes/config.php'; if(isset($_REQUEST["post_back"])){ $tb = $conn->prepare("select nm_usuario, imgPerfil, nome from usuario where…
-
1
votes2
answers23894
viewsUnable to locate driver (Pdoexception "could not find driver")
I’m trying to make a connection to my FIREBIRD database, but when I organize it right, I put the IP where it is located etc. The message appears: COULDN’T LOCATE DRIVER ON c/wamp/www//// What should…
-
1
votes1
answer124
viewsStore data in the database using PDO::commit
Hello... I never used PDO::Commit, but now I see the need to use ... and just now, even following the php doc and some examples on the net, I can’t store the data ... here’s my code: php connection.…
-
1
votes2
answers198
viewsHow to mount PDO query with items previously concatenated
The doubt is the following, in mysql we can concatenate a query and then perform the search, as follows: $cidades = '&& (cidade = 100 || cidade = 101 || cidade = 102)'; $order = 'id ASC';…
-
1
votes1
answer1304
viewsHow to manipulate data from the database using PDO
I’m starting to use PDO in my PHP projects. When I worked with mysql, without PDO, when I took a query in the BD, I was able to get each data associated to a variable and could do what I wanted with…
-
1
votes2
answers95
viewsForm recording the same data
Good afternoon guys. I have a problem that I can’t find a solution. I made a form to record the registrations of a web site , but often this being saved the same registration several times (see…
-
1
votes3
answers120
viewsProblem With PDO
My problem is this when I run this code below echo returns me 3 repeated values I could not figure out why you could give me a strength? : D <?php try{ $sql = $pdo->prepare("select * from…
-
1
votes1
answer62
viewsCorrect way to send values through PDO
I was informed that I was doing it incorrectly, the phrase said was the following: "It does no good to use a newer API and keep the vices of the old mysql_*, you should not pass the values directly…
-
1
votes0
answers167
viewsConnection database sql server 2008 PDO
I’m using the following code: try { $con = new PDO("sqlsrv:Server=ip;Database=nome","nome","12345"); $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } catch (PDOException $e) { die…
-
1
votes1
answer958
viewsError trying rowCount in PHP class
I’m trying to make a rowCount using a class I developed for the connection and some functions involving the bd. I have the following PHP class: class Banco { private $debug; private static $pdo;…
-
1
votes1
answer131
viewsTransaction history, how is it implemented?
I need to make a history of the user’s last (s) purchase(s) (these links will be shown in a table). Could you give me tips on how this history is usually saved? (don’t need to do it for me) Normally…
-
1
votes0
answers33
viewsWhat a PHP class would look like to do a database search with PDO
I’m trying to do mine framework, I’ve already managed to create a class called Model, within it has a function called getDataBaseConnection() and now how do I do it? I can’t create another function…
-
1
votes1
answer553
viewsInsert into foreign key tables with PDO
How to insert into tables with one to many relationship containing foreign key Hello everyone all right I’m having a doubt, I have a relationship between two tables in my mysql data ban as follows:…
-
1
votes1
answer1177
viewsChange image upload from mysql_query to PDO
I would like to change this code that is working with mysql_* for PDO: <?php if ( isset($_POST['enviar']) ) { $arquivo = $_FILES['arquivo']['name']; $update = mysql_query("UPDATE cabecalho SET…
-
1
votes1
answer1005
viewsRunning 2 queries at once is possible?
I need to change all fields of a table and only insert another result into a row. I am using the following code $Nid = intval($_GET['Nid']); $sql = "UPDATE * FROM programacao SET status='offline'…
-
1
votes3
answers4076
viewsSELECT with PDO and variable
How is it possible to make a SELECT in MYSQL with PDO next to this below: $buscarNoticiaTitulo = "noticias.titulo LIKE '%teste%'"; $sqlNoticias = $pdo->prepare('SELECT * FROM noticias WHERE…
-
1
votes1
answer138
viewsInsert error in database using PDO: "Only variables should be passed by Reference"
I am passing input parameters in the database using PDO and O, but when giving the Insert command using the parameters $stm->bindParam(1, $usuario->getnivel()); it returns error saying that I…
-
1
votes1
answer1085
viewsUPDATE with different conditions in the same query
How to update several records by setting different values, example: $update = "UPDATE tabela SET ativo=1, nivel=2 WHERE nome ='jose' AND nome='maria' AND nome='joao'"; then I just want Jose to…
-
1
votes1
answer253
viewsPDO - Class Not Found
What’s going on I created a static method to return the connection so I can use it on DAO, but in doing so it gives Class Not Found PDO. Other Projects The first thing a lot of people will think is,…
-
1
votes2
answers246
viewsProblem with INSERT using PDO
I have this code below that is working perfect, but I would like to change it to work in PDO but I’m having problem in the registration with BD, when I change to PDO. He refers to mistakes on line…
-
1
votes1
answer4960
viewsPdostatement::execute() error: SQLSTATE[HY093]: Invalid Parameter number
I have the following code, I used another similar to do a database update, but this now does not work; it gives the following error: Warning: Pdostatement::execute(): SQLSTATE[HY093]: Invalid…
-
1
votes1
answer80
viewsList as equal 3 column-Count
Well I think this is in css what is not my thing, I would like to be listing the results of the comic and pass the next result to the next column tried to use ( abridged) SELECT * FROM anuncios…
-
1
votes1
answer1269
viewsPDO connection to bank
Good guys, I’m starting to study about PDO, but soon in my first activity is occurring an error, follows below all the information. CODE Object.php <?php $cli = new Produtos(); $cli->insert();…
-
1
votes1
answer428
viewsPhp Mysql PDO connection on localhost by ip
I have a PHP/Mysql system in which I connect via PDO on the "localhost" host, but I will need to put the IP of the server "xxx.xxx.xxx.xxx" instead of "localhost", the system works but very slow. I…
-
1
votes2
answers80
viewsreturn the query as the zend string
I have the following code where I need to store inside the $erro_items variable the complete query with the parameters to analyze what is happening, my doubt is, how do I show this query? $sql = new…
-
1
votes1
answer67
viewsImage upload saves only first image in database
I have the following image upload code if(isset($_POST['upload'])){ //INFO IMAGEM $file = $_FILES['img']; $numFile = count(array_filter($file['name'])); //PASTA $folder = 'upload'; if($numFile <=…
-
1
votes1
answer1297
viewsGrab sequential ID based on last entered
I got a problem that’s giving me trouble. I have the following code: $sql = $pdo->prepare ("SELECT cpf,idUser FROM `tblContacts` where cpf = '".$cpf."' limit 1"); $sql->execute(); $row =…
-
1
votes1
answer3945
viewsCannot use Object of type stdClass as array
I made a code to check if the user and email are already existing, but when the user exists it returns the following error: Fatal error: Fatal error: Cannot use Object of type stdClass as array…
-
1
votes1
answer191
viewsSelect with Search conditions
I need to make a query where only display results in one condition: # Search the Database $select_sql = "SELECT * FROM users WHERE user LIKE :search OR date_access LIKE :search OR ip LIKE :search…
-
1
votes1
answer258
viewsPDO passing the bindValue parameter
I have the following parameter in my query UPDATE. $consulta->bindValue(':foto', $foto, PDO::PARAM_STR); What I would like to do is the following: If the variable $foto come blank, how could I…
-
1
votes3
answers182
viewsShow Quantity of items per category in virtual store?
I’m having a doubt: I have several categories on my site and would like you to show the amount of items you have in each category. Example: It’s like this: Accessories Toys Games Informatics I want…
-
1
votes0
answers56
viewsTurning this code into PDO
wanted to turn this query into PDO,? include 'config.php'; extract($_POST); $user_ip = $_SERVER['REMOTE_ADDR']; // check if the user has already clicked on the unlike (rate = 2) or the like (rate =…
-
1
votes3
answers1386
viewsUncaught Exception Pdoexception error with message 'SQLSTATE[HY000]: General error: 2014
I have a code that works perfectly on the local wampserver server, it is a query interspersing the result the problem is that when finishing the site and hosting it I get an error. The code is this:…
-
1
votes1
answer1362
viewswhile in infinite loop using $result = $result->fetch(PDO::FETCH_ASSOC);
<?php include ('pdo.php'); class crud { public static function select($arg){ $pdo = new pdoinit(); $result = $pdo->prepare($arg); $result->execute(); …
-
1
votes3
answers90
viewsInsert picture into 2 different tables
I created a Function to register images as an album; A table for capa and a table for galeria. THE HTML: //Imagem da Capa <div class="form-group"> <label class="col-md-1 control-label"…
-
1
votes1
answer199
viewsLogin with PHP using PDO
I already know how to register, but login is a bit complicated for me. I found some materials on the internet and I would like to know what the following line does. I know I’m collecting the form…
-
1
votes1
answer94
viewsproblems with infinite loop using PDO::FETCH_ASSOC
My Query $sql = "SELECT * FROM tablename WHERE algumvalor=2 LIMIT 1"; It’s going into infinite loop here How do I use while? while($row_data=$conn->executaQuery($sql)) { var_dump($row_data); }…
-
1
votes1
answer171
viewsWhat constant to declare in PDO::PARAM_ to insert date (yyyy-mm-dd h::m:s) in mysql?
I need to pass a date to the database. I will use the PDO class, but I have the following question. When creating "bindValue()" what kind of constant should I declare in PDO::PARAM_ ?