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
answers3709
viewsCrud Energy 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() {…
-
2
votes1
answer98
viewsI switched from mysqli to PDO and I can’t get Row
In my mysqli it was easy $_SESSION['userphoto'] = $row['userphoto']; How to make it work on PDO ? Connectionlogin.php session_start(); $stmt->bindParam(':email', $_POST['email']);…
-
2
votes2
answers1832
viewsMysql Automatically Change Data
Good afternoon, I wanted to implement a system that would make my database automatically, change the value of one of the fields of an element when the expiration date field was higher than the…
-
2
votes1
answer1573
viewsError "Insert value list does not match column list" with PDO
Hello, I’ve made a questionnaire, and it’s returning the following error: Error: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1…
-
2
votes1
answer1120
viewsHow the PDO::PARAM_STR parameter works in PHP+PDO
Example: $sth->bindValue(':calories', $calories, PDO::PARAM_INT); PDO::PARAM_INT This parameter is a kind of validation for data type ? If it is, why is there no error when I pass an integer?…
-
2
votes2
answers53
viewsReturn data difference from two sql tables
I have a table ESCOLA with ID_ESCOLA and NOME_ESCOLA and another table PROFESSORES containing a FK_ID_ESCOLA and NOME_PROFESSOR. I wanted a table that would return me the names of all schools but…
-
2
votes2
answers3113
viewsObsolete PECL/PHP PDO_OCI extension. How to proceed?
I need to install the pdo_oci extension of PHP to work with Oracle database, via PDO. However, I checked that the extension available via PECL is obsolete and will no longer be maintained. From what…
-
2
votes1
answer103
viewsCreate folder and upfile during same file
I want to insert a news along with the image file in a single post, the problem is that I would like to create a folder with the news ID where the image will be stored. It’s happening that the…
-
2
votes3
answers1036
viewsGrab last key from auto increment PDO
I have a problem with my system that is the following, try { $sql = "SELECT Nid+1 AS Nid FROM noticias ORDER BY Nid DESC LIMIT 1"; $stmt = $DB->prepare($sql); $stmt->bindValue(":Nid",…
-
2
votes1
answer393
viewsPHP PDO does not run UPDATE on the same SELECT page
Problem: make UPDATE work Question: Is the script correct? Request: Identify the reason for not doing UPDATE and generate error. Error: Notice: Undefined variable: db and Fatal error: Call to a…
-
2
votes1
answer120
viewsHow to intercept the result of a query?
I need to test if the query made everything went well or if there was an error. I tried however I did not find anything that satisfies what I need. Example: I submitted an sql in the database, and…
-
2
votes1
answer370
viewsPDO Selection in mysql database parameter BLOB
I am having trouble trying to rescue one or a list of images that I have already inserted in mysql 5 with PDO. I have a dao class that has the architecture of my querys to work with the database.…
-
2
votes2
answers522
views -
2
votes1
answer1150
viewsProblems with SELECT option with PDO
Friends reissued the PDO connection below: <?php $conn = new PDO( 'mysql:host=localhost;dbname=pbfjacar_site' , 'pbfjacar_murilo' , 'smc100164' ); $stmt = $conn-> prepare('SELECT font FROM…
-
2
votes1
answer979
viewsPrevent duplicate registration with PDO
I’d like to prevent the same source from registering for duplicities. The code used for registration is below: <form name="enter" method="post" action="" enctype="multipart/form-data">…
-
2
votes0
answers390
viewsLogout function using PHP PDO Object-oriented
I have a big problem with the function of displacing the panel, I made a public Function Logout() Filing cabinet Login.class.php: public function Logout(){ if($this->isLogged()) {…
-
2
votes1
answer131
viewsProblem with select dynamical to show dropdown menu for user
I am building the visualization layer for clients of a system in my database have two tables with relationships: and I have a method to return the results of these tables: public function…
-
2
votes1
answer346
viewsSQL LIMIT always returns the same last 3 records
I have a problem in a select. I have the following table id id_de id_para mensagem --- --------- ----------- ----------- 1 10 20 Oi David. 2 20 10 Oi José 3 10 20 Tudo bem? 4 20 10 Sim, e com vc? 5…
-
2
votes3
answers432
viewsInsert into seat with function
I’m trying to make an entry in the database using a function but I’m not able to enter the respective values; HTML: <?php if (isset($_POST['submitTexto'])) { inserir('empresa', $_POST); } ?>…
-
2
votes1
answer682
viewsReturn mysql result with function
I’m trying to list a database table using a function but I can’t use it outside the function: THE HTML: <tbody> <?php listar('empresa'); ?> <?php foreach ($row as $listar): ?>…
-
2
votes3
answers1602
viewsHow to add a database column using PDO
Good evening everyone. I have little experience in programming. I apologize if I am not very clear on the question. I have a Mysql database (phpmyadmin) with a table named "my table" having one of…
-
2
votes1
answer1061
views -
2
votes2
answers410
viewsHow to make an SQL query that returns an object instead of an array?
Not much to talk about. What I need is to know how to make a query that returns me an object instead of an array in the format: $eventos = [ new Evento(1, new \DateTime('2015-01-26'), 'Titulo #1'),…
-
2
votes1
answer561
viewsAdd X days on a predefined date in Mysql
I need to create a deadline, an access expiration date in the case I am using to capture the current time the "criado" datetime DEFAULT CURRENT_TIMESTAMP, Where I use the CURRENT_TIMESTAMP to get…
-
2
votes2
answers328
viewsMultiple registration of image
Here I come to ask for your help again! I created a function to register images in the database being one of them the cover and the rest of album images. The script up to register the cover image…
-
2
votes0
answers74
viewsWhat is the difference between PDO and Mysqli_?
I have been densevolving applications in PHP Mysql for a long time, and for norlamente I use the object PDO to connect with the base de dados and everything works perfectly. But today I decided to…
-
2
votes1
answer55
viewsPDO exec returning false
I’m doing an online course on PHP with PDO and I’m having problems right in the first class with the code: <?php $pdo = new PDO('mysql:host = localhost, dbname = curso_php_oop', 'root', '');…
-
2
votes2
answers82
viewsI am unable to call user information
User.php <?php class User { public static $Row = []; public static function Check() { global $PDO; $usersql = $PDO->prepare("SELECT * FROM users WHERE username = :username AND password =…
-
2
votes0
answers129
views -
2
votes2
answers146
viewsWhy don’t you update?
If you search only one like this and run the foreach it does the update but if you have more it no longer does... But if there’s more of one like in the other image it doesn’t change and it doesn’t…
-
2
votes1
answer417
viewsShow Image inside another
Galera So and I have this picture of wallet and I need to display another image on top of the case the photo of the person, I was able to enter the data searched from the bank but the photo of the…
-
2
votes2
answers157
viewsIf I declare a variable in a SELECT query is it required?
My problem is that I won’t always receive the variables, so I need a way that doesn’t make them mandatory even if I declare them, for example in the query below: "SELECT * FROM clientes WHERE…
-
2
votes1
answer446
viewsMysql UPDATE function is editing right, but creates a new empty row at the end of the table
I’m racking my brain here, because function UPDATE works well when used neatly by the terminal or Workbench, but when I do the PHP code via HTML form parameters, it edits neatly too, but creates a…
-
2
votes2
answers2006
views -
2
votes1
answer1120
viewsInsert with Pdo and OO
I have the following class that manages bank : <?php abstract class database{ /*Método construtor do banco de dados*/ private function __construct(){} /*Evita que a classe seja clonada*/ private…
-
2
votes1
answer155
viewsHow to work with IN instruction in PHP + PDO?
I’m trying to build a dynamic SQL but I’m getting beat up for not understanding how to work with the IN statement in PDO Example: $SQL = "select * from tabela where (campo in(:valor))"; $Query =…
-
2
votes0
answers40
viewsRecognition of SQL Server drives for db connection in PHP
I’m having trouble connecting to the SQL Server database. I can’t install the drives to be recognized. On the Internet I’ve tried every kind of thing and nothing has worked. I downloaded the drives…
-
2
votes1
answer49
viewsInsertion, editing, removal and visualization of data
I have a CRUD in PHP developed with the MVC standard, all interaction with the database is performed with PDO, my challenge is, pass all data requests asynchronously using Ajax and Json. I have only…
-
2
votes1
answer34
viewsDifficulty with PDO
I’m starting with the use of PDO and I have a doubt that I could not solve. I do the select below that will return me 2 hours: $sqlSaida = 'SELECT horario FROM HORARIOS WHERE COD = :codsaida UNION…
-
2
votes2
answers4834
viewsHow to check in the database if the registration has already been made PDO
How do I check if the id user no longer has registration in the database and continue with the insert? if(isset($_POST['submit'])){ $comment = trim(strip_tags($_POST['comment'])); $insert = "INSERT…
-
2
votes2
answers273
viewsHow to order day data in SQL with Unix Time Stamp (PHP)
Hello I’m with a doubt here, I’m creating a code to get how many users have logged on to my site today, but I saved the last date he logged on with Unix Time Stamp. I’m only able to get users who…
-
2
votes1
answer63
viewsHow I select several values from the same table
How do I select the values 1, 2, 3, 4 and 5 of the same table without doing that lot of SELECT ? <?php $rateone = 1; $ratetwo = 2; $ratethree = 3; $ratefour = 4; $ratefive = 5; $query = "SELECT…
-
2
votes1
answer27
viewscompare dates within the sql query
I need to compare the date registered in the bank +10 days with the current date and display the student that the current date is greater than 10 days, but this within the sql query. Is there a…
-
2
votes2
answers824
viewsPDO - Problem with Fetchall
Good afternoon friends, my problem today is the following. I have the following query: set @row_number = 0; SELECT @row_number:=@row_number+1 AS row_number,il.* from itemloja il order by il.LojaId…
-
2
votes1
answer255
viewsMysql result coming with bars
I’m using the http://summernote.org/, and when I send something to the database, for example, if I add this HTML tag <img = src="http://link"> in the editor, and send to the database, it saves…
-
2
votes1
answer10272
viewsHow to fix "1452 > a Foreign key Constraint fails" error using PDO in PHP?
First I know what is the mistake of Foreign key, however I do not know why it is happening in PHP code with PDO. Insertion function: function insert_pedido($cod,$pagamento,$total){ (int)$id = $cod;…
-
2
votes0
answers607
viewsPHP PDO connection with static variable in class
I did a research on connections using Singleton in PDO, in most people use a private or protected Construct so that if there is no connection the same is created when instantiating a new Class(),…
-
2
votes1
answer110
viewsa more efficient way to make the Insert bind and update large
public function update($table, $data, $where,$criterios) { $set = ""; foreach ($data as $keyname => $value) { $set .= ($set == "") ? "" : ", "; $set .= $keyname . " = " . ":".$keyname ; } $sql =…
-
2
votes2
answers2008
viewsHow to split an array and write to the PDO database
I have this code: <?php foreach ($_POST as $dados =>$value) { $list = explode('_', $value); echo '<pre>' . print_r( $list, TRUE ) . '</pre>'; ?> It generates the array output:…
-
2
votes2
answers63
viewsError adding elements in Mysql Database with PDO
I am having the following error while inserting into the database: Parse error: syntax error, Unexpected '{', expecting '(' in /var/www/public/Test/db/add-bank.php on line 18 Line 18 is: } catch {…