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
-
0
votes1
answer11482
viewsSQLSTATE[42000]: Syntax error or access Violation: 1064
I’m having trouble visualizing and entering the data in the database, is giving this error: SQLSTATE[42000]: Syntax error or access Violation: 1064 You have an error in your SQL syntax; check the…
-
0
votes0
answers96
viewsDouble Precision Firebird on PDO
Good afternoon, I am making a query in a table of Firebird using PDO PHP, and in a specific field of this table is returning all the same values in all records, this field is of type Double…
-
0
votes0
answers898
viewsSQLSTATE[23000]: Integrity Constraint Violation
I have an employee chart and address. The address is receiving a foreign key from the employee, however, is giving the following error when I will insert: Exception 'Pdoexception' with message…
-
0
votes1
answer76
viewsPDO data entry, doesn’t it work?
I am trying to create a registration page with PDO however, it does not perform the insertion and does not present error, which can be? include "../pages/sqlconn.php"; $name = $_POST["name"]; $email…
-
0
votes2
answers88
viewsGroup a set of measures in PHP
I’m having a problem uniting a set of values. I have a wood marking system. I feed the database with the length x width of the wood Id, id_request, length, width, date Registros: 1, 3, 320, 20,…
-
0
votes1
answer123
viewsWhich type of PDO::FETCH_* is the fastest?
Of the ones I know, there are 5 ways to accomplish, but at official documentation is presented about 8 different ways of performing a FETCH_*. I would like to know, in every way to make one…
-
0
votes2
answers261
viewsTranslate mysql_query to PDO "UPDATE * SET... WHERE..."
Hello, I recently started translating my sites to PDO for obvious reasons. Yet this one is giving me a bit of a headache. $sql = mysql_connect("localhost", "user", "pass") or die(mysql_error());…
-
0
votes4
answers842
viewsWrite MYSQL data in en / UTF8 format
As I do to save data in the database in Brazilian format with accents, I used it in connection mysqli_set_charset($conexão, 'utf8'); but now my code is all in PDO as I do to save this data in utf8…
-
0
votes0
answers114
viewsSave multiple data from textarea PHP and PDO
Good morning, I have the following script that I need to save all data from the textarea line by line but the script saves only the first line and ignores the rest receive the data so in textarea…
-
0
votes1
answer102
viewsKnow Count() output in query
I have the following query on Pdo: $ranking = $pdo->query("SELECT * FROM usuarios GROUP BY moedas ORDER BY count(moedas) DESC LIMIT 3"); I use this to make a ranking to know users with more…
-
0
votes1
answer687
viewsError while trying to execute Insert PDO function - PHP
I’m trying to create a PDO function to perform two inserts, one after the other, but I’m having difficulties. The function code is: public function double_cad(array $dados){ $pdo = parent::getDB();…
-
0
votes0
answers79
viewsHelp with login by SQLITE
I’m making a login simple here via Sqlite, but at the time of pressing the "Login" button, says that there is no ("Login Failed") everything is correct on the form; $sqlite = "sqlite:teste.db"; $pdo…
-
0
votes2
answers219
viewsError using $this in static function
I’m trying to use a class function as follows: $database = database::select("SELECT * FROM eventos"); When I run the code, it returns the error: Fatal error: Using $this when not in Object context…
-
0
votes0
answers50
viewsProblems with scope in php, can anyone help me please?
I have some classes, I will post them to you can then explain my problem which is quite simple. class connection to the database <?php /* * Gerencia conexões com bancos de dados, * usando…
-
0
votes1
answer31
viewsHow to run the same query for different "ids"
I have an array with the following Ids: Array ( [0] => 2 ) Array ( [0] => 3 ) Array ( [0] => 5 ) The query should return all the values found for these Ids, so, how will the assembly of the…
-
0
votes1
answer214
viewsMysql connection security using PDO, am I doing right?
It is safe to connect with Mysql only using the following form below? <?php function conectar() { $server = "localhost"; $dbname = "banco"; $dbuser = "usuario"; $dbpass = "senha"; try { $con =…
-
0
votes1
answer308
viewsSave array to different columns with fputcsv
I am trying to output some data from BD to csv with the following code: while($linha=$buscar->fetch(PDO::FETCH_ASSOC)){ fputcsv($out, $linha); } fclose( $out ); } which returns all the contents…
-
0
votes1
answer148
viewsCreate database through PDO
I have a project in mind, in which I would like to create database with the name of variables, and in case it would be done a check to know if the BD has been created, would be something like this:…
-
0
votes0
answers49
viewsMake Insert with select
I have a table called label, with nameTag varchar and Quant int 11. When I insert in the label table, I have to increase the total quantity registered in the bank +1. But I don’t know how to do this…
-
0
votes0
answers109
viewsDoctrine2 + pdo_sqlsrv createQueryBuilder Order By with varchar field does not work
I’m creating a method that takes values for createQueryBuilder() from parameters. I tested in my local database with pdo_mysql driver and it worked perfectly, sorting both by a field of type int…
-
0
votes1
answer64
viewsHow to save the highest value of rowCount?
I want to save in a variable the highest value ever obtained by rowCount I just don’t know how to make the logic. Current consultation: $playeronline = $pdoG->prepare("SELECT login FROM u_hero…
-
0
votes3
answers1192
viewsHow to obtain the line number of a SELECT statement in PDO?
How do I know how many records I have returned from a SELECT statement? I tried using rowCount() but this did not work in my code, I just want to return to me the amount only this. $contador =…
-
0
votes1
answer2083
viewsHow to sum the values of an SQL column
I need to make a system that takes the three biggest donors. My table: donate_ID | donate_NAME | donate_AMOUNT This donate_NAME can be repeated, and if this happens its value will be added with the…
-
0
votes1
answer102
viewsError due to PHP UPDATE with PDO
This code cannot find the records, and brings that variable $lista is undefined. My HTML: <html> <head> <meta charset="UTF-8"> <title></title> </head>…
-
0
votes0
answers32
viewsUncaught Exception 'Pdoexception' with message 'SQLSTATE[HY093]: Invalid Parameter number: Parameter was not defined
Fatal error: Uncaught Exception 'Pdoexception' with message 'SQLSTATE[HY093]: Invalid Parameter number: Parameter was not defined' in D: htdocs sistemas imobiliaria admin classes imovel.php:603…
-
0
votes1
answer260
viewsGet the repeated records from one column from another column
Hello to all! I am facing the following problem: I want to get the amount of values that repeat in the column disease type from the column of locality, that is to say, take the amount of records…
-
0
votes1
answer24
viewsPDO Doubt SQL Injection
I am venturing a little with PDO, still at the beginning, and I have a question regarding a query with SQL Injection, follows it: $insert = "INSERT INTO tabela (campo1, campo2, campo3) VALUES…
-
0
votes1
answer45
viewsHow I select all records from the table
How do I select all records in select below: $select = "SELECT COUNT(1) AS id_mark, SUM(a.rate) AS rate, b.name_mark, b.id FROM tb_comment a, tb_mark b WHERE a.id_mark=b.id AND b.id_category=:id_c…
-
0
votes2
answers38
viewsHelp Foreach stdClass
Good morning :D I need a light! I need to take all 'ids' of users of a table and pass to another table, but when I give a foreach it returns me only 1 result as stdClass. Follows the code: $stmt =…
-
0
votes2
answers516
viewsInsert with PDO and INNER JOIN
I have a table person who owns the fields name, city and phone and time_id. I also have another table with a team name and in it I have a field called meu_time, as I can do an INNER JOIN to register…
-
0
votes0
answers261
viewsMysql hangs when trying to query table with many records (PHP)
I am trying to make a filter where the query is done in a table where the id of the last record is in the number 468.466. In the filter, I need to make a comparison with a View, which has your id…
-
0
votes2
answers170
viewsI cannot update because it is not recovering php Pdo id
Here is to recover in html: if(isset($_GET["id"])){ $administrador = new Administrador(); $mostrar = $administrador->listar_id($_GET["id"]); } <form action="Crud.php" method="post"…
-
0
votes1
answer28
viewsI cannot declare variable inside id
@$c_id = $_POST['numero']; @$data_aa = $_POST['data_aa']; // Data esta vazio if($data_aa == ''){ $var = "oi"; echo "$var"; } If I put the variable $var outside the if(), works normally.…
-
0
votes1
answer536
viewsSafe way to use PDO?
I’m starting with the class PDO and I have insecurity in working with it, is that I am working in the safest way (when we speak of data security)? I know there are hundreds of parameters on PDO, as…
-
0
votes1
answer162
viewsPDO bindParam error
I have a function of UPDATE which takes table, column array, values and Where, I do the treatment: //montar SQL $totalValores = count($valores); //conta quantos valores $expressao = null; for($i =…
-
0
votes0
answers64
viewsHow to make data return in php array
I need to return the data in an array. I’m doing it, but the data doesn’t return: <?php ini_set('display_errors', true); error_reporting(E_ALL); include_once("conexao.php"); $pdo = conectar();…
-
0
votes1
answer75
viewsPDO does not execute query
I have a form that does a search via PDO, only when I run, it does not return me anything. $PDO = db_connect(); $busca = $_POST['usuario']; $vbusca = "%".$busca."%"; $sql = 'SELECT nome, tipo, cor…
-
0
votes2
answers49
viewsHow to query multiple columns
How can I query in several columns the value equal to the field using PDO $PDO = db_connect(); $busca = $_POST['campo']; $vbusca = array("%$busca%"); $sql = 'SELECT * FROM livro AS t WHERE nome LIKE…
-
0
votes2
answers37
viewsProblems when performing INSERT (PDO)
Good afternoon! I’m encountering problems to perform the following insert: function cadastro($usuario,$senha,$status){ $pdo = con(); $usuario = "Matheus"; $senha = "123"; $status = 3; $inf = […
-
0
votes2
answers764
viewsHow to query data from a table using INNER JOIN in a sub-query in PHP
I have the following SELECT to select data from a table (chat) in a chat system: SELECT * FROM (SELECT * FROM chat WHERE id_chat = '$chat_id' ORDER BY id DESC LIMIT 10) S WHERE id_chat = '$chat_id'…
-
0
votes1
answer394
viewsHow to make an INSERT inside the while
Hello, How do I insert into a loop where id of the comment = id of the comment look at the code $selecionarComentarios = $conexao->prepare("SELECT a.id_mark, a.id_user, a.comment, a.rate, a.id,…
-
0
votes1
answer207
viewsProblems with accentuation in Postgresql and PHP characters
Hello! I’m having trouble saving data from a PHP form in Postgresql. Currently the database is LATIN1 and the pages are with Charset in UTF8. However I have tested with Postgresql in UTF8 and the…
-
0
votes1
answer77
viewsPopulate html select with database values
Good morning, I’m a beginner in php and I’m creating a personal project to register people. I have a screen that lists all users and when clicking change user, it returns the values of the user in…
-
0
votes2
answers78
viewsSQL + PHP Query: Take only data from the current year from January to Today?
I need the return of data between 01/year to the present day. But I’m still not very familiar with SQL and PHP date(); Here is the excerpt from the code: $startMP = date('Y'); 'BETWEEN '{$startMP}…
-
0
votes0
answers60
viewsHow to get next code from a table in pgsql?
In Mysql I use the syntax SHOW TABLE STATUS LIKE 'NOME_DATABELA' How I capture the report in Postgres?
-
0
votes0
answers22
viewsDisplay records in order according to the quantity you have in a table
I have two tables in the database, one is saved all the groups and the other the members of the groups. I want to make a page of Popular Groups, would display the groups that have more members in…
-
0
votes1
answer69
viewsValue x PHP input
Code is this: Page edits: <?php $id = ""; $DsStatus = ""; if(!empty($_GET['id'])){ $id = $_GET['id']; $results = $controller->listar($id); $DsStatus = $results->getst(); } <form…
-
0
votes0
answers80
viewsQuery by table text using PDO
My seemingly simple problem has given me headaches. I have a table that contains three columns: id, idpergunta, resposta. When a reply is sent to be inserted in this table I check if it already…
-
0
votes1
answer66
viewsInsert data into database using PDO
$servidor = "localhost"; $usuario ="root"; $senha=""; $db="pdo"; $conexao = new PDO('mysql:host = localhost; dbname = pdo', $usuario,$senha); $stmt = $conexao->prepare('INSERT INTO…
-
0
votes1
answer70
viewsCorrectly insert data into table
I’m in serious trouble with the INSERT of PDO, I am unable to add the values correctly to the banco de dados, how to proceed in this situation? Picture of the problem: I’m waiting for help. <?php…