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
-
2
votes2
answers9602
viewsGenerate csv file in php
Hello guys I am trying to create a php query in mysql database to generate a csv file according to the code below. The problem is that the part that would download the file is showing error, I…
-
2
votes1
answer157
views -
2
votes0
answers99
viewsSelect MYSQL, list row not present in NULL table
I’m making a hotsite with a quiz (questions and answers), with more than 3000 users. The question is in the list of quizzes for each user, I have two tables (simplified to focus on my question):…
-
2
votes2
answers1970
viewsPHP error with Sqlserver Exception 'Pdoexception' with message 'SQLSTATE[08001]: [Microsoft][ODBC Driver 11 for SQL Server]
I installed the right driver in PHP, added the extension in php.ini, but when I try to connect with PDO on sqlserver, this error appears: Exception 'Pdoexception' with message 'SQLSTATE[08001]:…
-
2
votes0
answers174
viewsUPDATE PDO, AJAX, PHP Object-Oriented
I have the following function within my class public function update(){ try{ $stmt = $this->conn->prepare("UPDATE Tabela SET Dado1 = :Dado1, Dado2 = :Dado2, Dado3 = :Dado3 WHERE DadoId =…
-
2
votes1
answer55
viewsHow to send variable value into php class?
I have been perfecting the techniques of safe use with database connection and arrived at the script below. <?php class query_sql { protected static $conect; private function __construct() {…
-
2
votes1
answer501
viewsHow to list multiple columns using Inner Join and left Join?
How can I get data from two tables? Example. the fields `assunto,nomeremetente,cpfremetente,observacao` da tabela **protocolos** and the datacriacao table protocolo_documents is of the…
-
2
votes1
answer250
viewsError while performing sql server + php + Pdo query
Follows the code: $conexao = new PDO("odbc:Driver={SQL Server};Server=127.0.0.1;Database=MASTERDB; Uid=admin;Pwd=admin123;"); $select = $conexao->query("IF Object_ID('tempDB..#TabBatidas', 'U')…
-
2
votes1
answer288
viewsProblem with login system - array
Hello. I am creating a login system for study purposes. I identified in the file that is not populating the array with the database information... and yes, I have already made sure that the email…
-
2
votes1
answer63
viewsHexadecimal string cut when doing Insert with PDO
Good afternoon, you guys! I would like some help from you to solve a problem that is happening to me. I have a hexadecimal string containing an images that should be added to the database, when I do…
-
2
votes1
answer109
viewsMultiquery PHP PDO - SQL Server 2012 - IIS 8.5
Is there a problem with running multiple queries with the same PHP PDO code? Example: <?php // Retorna $con include 'conexao.php'; // Suponhamos que dbo.minha_tabela tenha apenas três campos,…
-
2
votes2
answers311
viewsExtended PDO connection does not work
The netbeans IDE does not show any errors, but when I try to run it always gives error in the browser, does anyone know what is wrong? can tell me how to use connection with father class builder…
-
2
votes2
answers686
viewsDistinguish equal fields in a SELECT with LEFT JOIN
In a SELECT done in two tables with similar fields I would like to distinguish the field of each table when displaying the results. For example: $sql = BD::conn()->prepare("SELECT a.*, b.* FROM…
-
2
votes4
answers4228
viewsHow to perform query with some null values?
The SQL below returns the values correctly only if the field data_emissao be as nonzero in my BD table (independent if the parameter cliente was passed or not), but I wish to return the values where…
-
2
votes2
answers572
viewsmysql with single PDO result
I’m trying to create a query as follows: I have a table in the database with this structure: name | address | status The status field only has 2 types of values 1 or 0. I want to count all records…
-
2
votes1
answer41
viewsError updating AUTO INCREMENT
I have the following code: $sql='ALTER TABLE tributos_prod AUTO_INCREMENT=:ultimo_id'; try { $query_delete=$conecta->prepare($sql); $query_delete->bindValue('ultimo_id', $ultimo_idTP+1, PDO: :…
-
2
votes1
answer104
viewsSearch in multiple tables
Hi, I’m trying to search 3 different tables, check my code: $buscando = $pdo->query("SELECT * FROM filmes WHERE nome LIKE '%$busca%' AND status='ativo' ORDER BY nome ASC"); The tables would be:…
-
2
votes1
answer41
viewsIs my database access function 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…
-
2
votes0
answers375
viewsConnection to external database
I created a database on 000webhost and created a PDO connection to access it from my localhost in vertrigo <?php //CONSTANTES define('HOST', 'databases.000webhost.com'); define('USUARIO',…
-
2
votes1
answer3219
viewsWhy the PDO error Uncaught Error: Call to Undefined method PDO::fetch()?
I don’t know why I made a mistake. Fatal error: Uncaught Error: Call to Undefined method PDO::fetch() in /opt/lampp/htdocs/myschool.com.br/login.php:24 Trace stack: #0 {main} thrown in…
-
2
votes1
answer183
viewsSelect with PDO and SQL barring HTML
I am trying to make a Select with PDO and MYSQL, but when I put php code in the middle of my html it does not allow the execution of the rest of the page. follows the code excerpt: <select…
-
2
votes1
answer226
viewsproblem with namespace and PDO
Well I got a class Sql extending PDO, but when I define a namespace the following error message appears when creating an object from the Sql class: Fatal error: Class 'PDO-related classes' not found…
-
2
votes0
answers33
viewsPDO class, how to prepare really avoids SQL Injection s
underlined textHello, I am studying PHP and, regarding POO together with PDO, I have the following question: I always see in the articles in this regard, that making use of the PDO statement:prepare…
-
2
votes0
answers156
viewsTwo databases with PHP PDO?
I’m trying to make a connection to two databases with PDO ta thus. Config.php <?php class config{ var $host = 'meuhost'; var $usuario = 'meuusuario'; var $senha = 'minhasenha'; var $db =…
-
2
votes1
answer518
viewsSave user data to session after login
On the login screen I make the query to free the access to the system, after that I would like to make a complete query of the data of that user and to write in the SESSION. <?php // inclui o…
-
2
votes2
answers1017
viewsMultiple insert with php PDO and Mysql
My situation, A post form with a text input and two radios inputs. Inputs are named respectively, nome[0] and tipo[0]. When one adds more form fields I put one .attr to stay nome[1] and tipo[1]" and…
-
2
votes1
answer121
viewsTable very slowly using Datatable
I’m bringing in 3,000 records from the MYSQL database using a connection to PDO and PHP. The time to be taken costs around 40 seconds to present all the data. Is Datatable unable to bring data by…
-
2
votes2
answers98
viewsUsing PDO links in PHP
I am trying to create a loop with PDO where I can choose the desired field to position it on the page. But the code I’m using is bringing all the fields at once. My code is like this:…
-
2
votes2
answers436
viewsSQL parameter in PDO PHP does not work
The following code returns 11 records from the database: $dbh = new PDO('sqlite:db_coleta.sqlite3'); $sth = $dbh->prepare('SELECT * FROM ROTA_VIEW WHERE usuario_id = 1 AND 0 = 0');…
-
2
votes1
answer193
viewsUsing $this when it’s not in the context of the object
I am trying to create a PHP class that connects to the Mysql database and am getting the following error: Fatal error: Using $this when not in Object context Connectdb.class.php class ConnectDB {…
-
2
votes1
answer113
viewsError when checking user duplication
I wanted to prohibit the user from registering two iguas users, like two identical emails or matricula, but is still being recorded existing data, After that press in register and send the data to…
-
2
votes1
answer137
viewsHow to pass mysql table field name as parameter via PDO PARAM?
I have a form where the user sets some criteria for the system to do a search for data in a mysql database. Among the criteria, the user can choose two search options. These options are two fields…
-
2
votes0
answers35
viewsDifficulty Creating a Simple Variable Parser for Altorouter
I did a Simple Check of Variable PHP, but it was developed in Mysqli Base, the fact and that I went through some problems and due to this, I was forced to pass all the code to PDO, the problem and…
-
2
votes1
answer44
viewsI can’t place a database data in a value of an input from my form
This is a CRUD in php where the only option missing is the editing of a register, it happens that I intend to use the same form The problem is that when I click edit the fields of value inputs…
-
2
votes1
answer104
viewsProblem with Bindvalue and PDO
Hey, guys, good afternoon. I’m having trouble connecting by Bindvalue to my variable, note that I made the call, asked to return the values with Fetchall and it is returning an empty array. When I…
-
2
votes1
answer131
viewsCount quantity shopping cart
Good evening, I need to count the amount of products that are in the cart in the quantity field. I am using PHP PDO and MYSQL TABLE id | quantidade | produto 1 | 5 | 582 2 | 8 | 122 The total needs…
-
2
votes1
answer169
viewsHow to UPDATE with AJAX + PHP + PDO
I’m trying to do an Update with AJAX and PDO, but I’m not getting it. I’ve tried several ways and I can’t adjust the code. It is affecting only the last registered id. Can anyone help me please?…
-
2
votes1
answer76
viewsExtension . pdf does not download php
Good night, I have a table in the database that registers files(pdf,img,png and etc...) called billets: CREATE TABLE boletos ( protocolo int(11) NOT NULL AUTO_INCREMENT, boleto mediumblob NOT NULL,…
-
2
votes0
answers552
viewsMysql consuming a lot of memory
My server is set to limit mysql memory usage by 70%, at all times mysql is at 73.8% or even 74%, even when almost no one is using the system gets like this, ai from time to time error in someone…
-
2
votes0
answers21
viewsPagination of mysqli for PDO
Good afternoon, I’m trying to develop a page system for my tables, and already had a code in mysqli so I decided to take advantage, but I had to change to Pdo and it doesn’t work. The code so far…
-
2
votes0
answers55
viewsPHP error with PDO and SQLITE, Call to a Member Function execute() on bool
Hello, can anyone see why this error is apparently all right function verificarImportados(){ define("DB_DSN", "sqlite:host=localhost;dbname=dbXML.db"); define("DB_USERNAME", " ");…
-
2
votes2
answers149
viewsCondition in PHP "if" to know if the sent Mysql command worked or not
I’d like to know what condition to put inside the if using PHP with Mysql database so it is possible to know if the command returned an error or not. As seen in the code below, I want to delete a…
-
2
votes1
answer92
viewsWhat is the right way or how to close persistent PDO connections in PHP?
I need to close the connection to the Mysql database in PHP in the code below: try { $conn = new PDO('mysql:host=localhost;dbname=banco', "root", "", array(PDO::ATTR_PERSISTENT => true));…
-
1
votes2
answers452
viewsHow to make the return of a query (PDO) bring me an array already?
I have that I have : Periodo | Cliente _________________________ jan2014 | Cliente A jan2014 | Cliente B The one I want : array( 'jan2014' => array( 0 => 'Cliente A', 1 => 'Cliente B', ) )…
-
1
votes2
answers37
viewsDoctrine DBAL dev version
See only the dev version is paid :? I’m talking because you’re making a mistake again: "C: bin Composer.bat" "-ansi" "-no-Interaction" "validate" . /Composer.json is invalid, the following…
-
1
votes0
answers53
viewsPrevent SQL attacks via $_POST x-Editable
Is there any way to prevent SQL attacks on $_POST, whereas he gets every kind of value, url, name, date and some special characters. I’m using the plugin x-Editable (former Bootstrap Editable).…
-
1
votes1
answer899
viewsWhat are the advantages of PDO::FETCH_OBJ?
What are the advantages of using PDO::FETCH_OBJ? I know it returns me an object instead of an array, but what are the advantages of code performance?
-
1
votes1
answer130
viewsPortfolio organization by categories
Analyzing the MODEL, would like some simple suggestion to classify these blocks by categories dynamically with the same existing effects. I have a table that saves the "product" id and the…
-
1
votes1
answer1795
viewsPDO mysql php accentuation problem
I am using this class to manipulate records in Mysql using PDO http://www.imavex.com/php-pdo-wrapper-class/ But I suggest ééé and inserts me éé at the bank the database is uft8 the script header…
-
1
votes1
answer384
viewsBatch Insert using Pdo and transaction
Good morning guys I’m a little new in the world ai php mysql and I’m in need of a help I am inserting data in my bd in 6 tables, data comes from txt files some files have 5000 lines with 163 records…