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
-
4
votes0
answers394
viewsPHP Class PDO works all CRUD on the local server when the select works
I have a problem that I could not solve. I have already researched here and found nothing like it. I have a PHP application, using the PDO class for database connection. So I got her the CRUD:…
-
4
votes2
answers6065
viewsCounting lines reached PDO
I’m doing a query and need to count the number of returned lines, I’m not usually used to doing this in PDO, follow my code below. $sqlCODCEL = $conn->prepare("SELECT * FROM tbl_CELULAS WHERE…
-
4
votes2
answers369
viewsHow to add everything in MYSQL
How do I sum everything from a table in Mysql for example.. I have the table tb_comment, then I want to add in each post(id_mark) the amount of rate it will have in total. For example the id_user 20…
-
4
votes2
answers1031
viewsWhat’s the difference between bindValue and an array executed directly in $Pdo->execute()
Currently I use a schedule like this <?php $array = array('nome'=>'Alisson', 'idade'=>20); $query = $conn->prepare("INSERT INTO table (nome,idade) VALUES (:nome, :idade)");…
-
4
votes1
answer85
viewsEfficient execution of PHP PDO queries
Is there any performance difference in the codes below? $result = $pdo->query($sql); foreach($result as $reg){ ... } and... foreach($pdo->query($sql) as $reg){ ... } I’ve run some tests, but…
-
4
votes1
answer354
viewsChange a Select mysql to a Select PDO
I have a select of sources registered in a table, and I currently use this code to list them so that the user can choose the desired source. <select name="tipo_font_end"> <?php $select =…
-
4
votes2
answers703
viewsHow to save multiple users to an account like Netflix for example
Next, I have an application that supports only 1 account per user, I want to update the database on MySQL so that it supports a system that can be saved for example, child accounts, derived from…
-
4
votes1
answer54
viewsFunction for file upload
I’m trying to create a function that takes 1 value from a input do tipo texto and 1 file. I was able to move the file to the folder but I’m not able to develop SQL to insert the file name in the…
-
4
votes2
answers114
viewsInsert Mysql PDO
Well, I need to do an insert and I use PHP OO, but how do I do this? According to my code is registering, but is not working perfect. I’m doing something wrong ? Do not give any error message, just…
-
4
votes2
answers790
viewsWhat are Try/Catch blocks?
I would like to know what the blocks are try...catch. I would like more information in Portuguese, because in English I didn’t understand much, only that it would be a kind of if...else. What are…
-
4
votes3
answers287
viewsDo you need to use the third bind* parameter?
I would like to know whether you should use the third value of bindValue() / bindParam()? For example: $resultSQL->bindValue(1, $email, PDO::PARAM_STR); Or there’s no need for me to use:…
-
4
votes1
answer236
viewsWhat are the differences between Adodb and PDO?
What are the differences between Adodb and PDO? Which one has the best performance?
-
4
votes1
answer291
viewsPDO shows no errors
My connection code shows no errors, what’s the problem, I searched several places and found nothing about it: class Connect { protected static $db; public function __construct() {} public static…
-
4
votes1
answer72
viewsPDO without JSON support
I need to return a line in JSON, but the PDO does not seem to give full support to operations. Always the error message type 245. PDO::prepare(): Unknown type 245 sent by the server. Please send a…
-
4
votes1
answer11463
viewsError Object of class stdClass could not be converted to string
Well I have an 'X' object that one of its properties is a JSON. In this JSON contains the column name and the column value respectively. But I can have several 'X' objects, and so on. Today I’m…
-
4
votes1
answer200
viewsProblem with dynamic PDO UPDATE
I’m creating a CRUD dynamic in Pdo, where I receive several parameters within an array, and within that array there may be several other arrays. The problem is appears when I am mounting SQL. I…
-
4
votes2
answers7486
viewsAn Exception PDO occurs when localhost is used as a host
Consider the following adaptor class DbAdapterMySQL that extends the class PDO: class DbAdapterMySQL extends \PDO implements DbInterface { public function __construct(array $config) { $dsn =…
-
4
votes2
answers792
viewsPDO vs Doctrine
Work with systems development in PHP, more focused on e-commerce. Currently I use the PDO to make my connection to a database, but out of curiosity I decided to search about the Doctrine, because…
-
4
votes1
answer954
viewsConnection Progress database by PHP (Laravel framework), PDO
I need to connect to a Progress database via php I am using the framework Laravel 5.2 however the same according to the documentation only has support for Mysql, Postgres, Sqlite and SQL Server…
-
4
votes2
answers1111
viewsI am unable to configure the sqlsrv drivers in php7
In the archive php.ini all extensions are found, except the ones I need to connect to SQL Server database. extension=php_sqlsrv_7_ts_x64.dll extension=php_pdo_sqlsrv_7_ts_x64.dll As .dll are in the…
-
4
votes4
answers882
viewsUpdate the data in the database without changing the others that already exist - PDO
Hi, I’m trying to create a page to change the registration data with mysql database, but it should only update the data that are filled and not change the other data if it already exists in the…
-
3
votes1
answer306
viewsPDO deletes columns with equal names
I realized that by using the PDO to execute the query below, the results are conflicting with the PhpMyadmin and the Console do Mysql: SELECT a.*, n.* FROM arquivo AS a INNER JOIN numeracao AS n ON…
-
3
votes1
answer576
viewsError making dynamic PHP Insert
The code that is causing the error: public function Inserir($tabela,$sql){ ksort($sql); $Campos_nome= implode('`, `', array_keys($sql)); $Campos_valor= ': '. implode(', :', array_keys($sql));…
-
3
votes3
answers480
viewsCheck whether $_GET value is 1 or 2 and run SQL UPDATE
I have the $_GET['id'] and I need to check if the value it takes from the url index.php?id= is 1 or 2, and if none of the alternatives runs a die();, if it is 1 or 2 assigning $var = $_GET['id'];…
-
3
votes1
answer49
viewsPDO showing connection data if catch trigger inside Alert(result)
Because in my alert(result) ajax the catch of PDO is showing my connection information to the database as shown in the following image: http://puu.sh/bel2Z/e7f230ab8d.png Code: $pdo = new…
-
3
votes1
answer1552
viewsHow to connect to an existing Sqlite database using PDO?
I want to connect to a database that already exists using PDO and sqlite in PHP, and here is the code I have: class Database extends PDO{ public function __construct(){ parent::__construct("sqlite:…
-
3
votes4
answers2051
viewsLeave last 12 records and delete the rest in PHP/Mysql
I would like to make sure that after running the script, there can only be the last 12 records in a specific table that has the date field in international format if it can assist. <?php # Este…
-
3
votes0
answers378
viewsHow to see the final query that was executed? PHP PDO
I make my appointments as follows: $sql = "Select * From minha_tabela Where meu_campo = :parametro"; $sql = $db->prepare($sql); $sql->bindParam(":parametro", $parametro, PDO::PARAM_STR);…
-
3
votes2
answers477
viewsHow to use PDO bindParam in query IN()?
I have a query similar to this: $modelos = "1,2,3,4"; $sql = "Select codigo_modelo, nome From modelos Where codigo_modelo in (:codigo_modelo)"…
-
3
votes4
answers20245
viewsPDO:: Fetch & Fetchall
Because the following code works: $stmt = $pdo->prepare("SELECT * FROM dados"); $stmt->execute(); $codigos = $stmt->fetch(); echo $codigos['codigo']; And so I can’t use? $stmt =…
-
3
votes2
answers4434
viewsAdding numbers from a Mysql column using PHP
I have several results in the Mysql database, I want to take the results and sum all the numbers in a column, in PHP. How do I?
-
3
votes1
answer4523
viewsHow do I select in PHP With FIREBIRD PDO?
I have already made a correct connection with Firebird using PHP, however I would like to know how I can make one select in a certain bank. Can someone please help me? <?php $user = "SYSDBA";…
-
3
votes3
answers284
viewsCreate folder and ID simultaneously using the same id number
I need that when the user is entering a new article to be created a folder with the same number as the article ID. <?php include './includes/config.php'; setMenu("Notícias"); include…
-
3
votes1
answer94
viewsCharset Mysql and PHP
My mysql table is UTF-8 formatted and all accents appear correctly, but when I request with PHP and display the data they do not appear in UTF-8 format. p.s: my page already has the goal for utf-8.…
-
3
votes1
answer115
viewsError in PDO database
I am creating a page that saves values in the Mysql database using PDO and is not writing the data. I am using the following code: <?php $conexao = new PDO('mysql:host=localhost;dbname=dbTeste',…
-
3
votes1
answer265
views -
3
votes1
answer923
viewsHow to sort and filter queries between two tables?
I have two tables, one of posts (posts) and another of friends(Friends). In my script there is an area of feed where I would like to present the latest posts from the logged user’s friends. But…
-
3
votes2
answers824
viewsPDO connection does not give error, nor with dummy bank
I’m starting with PDO. I’m trying to connect with the bank and I can’t. I have the following code $host = "localhost"; $user = "root"; $pass = "root"; $dbname = "angularDB"; try { $pdo = new…
-
3
votes1
answer167
views -
3
votes2
answers7460
viewsHow to list table-specific data with PDO?
How to list data specific of a table, but using PDO? I’m starting to study and use PDO, however to some things that I am not able to find and that is well explained of how to read the data with a…
-
3
votes1
answer251
viewsWhich PHP extension should I use with SQL Server 2000?
I am trying to connect to SQL Server 2000 database using PHP PDO SQLSRV, but when accessing index return me the catch() with the following error SQLSTATE[08001]: [Microsoft][SQL Server Native Client…
-
3
votes2
answers10563
viewsFormat/mask CPF in Mysql or PDO
I have a field "Cpf" in my table. This field can be of type INT or VARCHAR, in case you need to change to solve my problem. In it there are only numerical values, without the dots and without hyphen…
-
3
votes2
answers2411
viewsUncompressed data with Internet JOIN using PDO
Hello I’m having problems when I’m returning a select made with some tables Inner Join as shown below: So I set up a Join Internet with my needs in my method: public function tableUsuarioUM() {…
-
3
votes1
answer5744
viewsReturn error message for queries in PHP database
Is there any way to receive error messages from the database when trying to execute a Query with PHP PDO? I’ve tried to get one try catch in the method ->execute() but the class PDOException…
-
3
votes3
answers671
viewsHow to make SELECT in more than one bank table?
I have two tables in the database: zip code and users. Can I do a single query to get fields from both tables? Both have idCep. I want to get the address data of the cep table and the name and user…
-
3
votes2
answers295
viewsSave bank value to same user
I have a page with a field for entries that are recorded in the database and when recording I assign a user ID randomly in this register. Thus: $name = $_POST['name']; $phone1 = $_POST['phone1'];…
-
3
votes1
answer83
viewsPDO with Emulated prepares is unsafe? What’s the difference?
I recently did some research on the internet and noticed that several people say that PDO does not protect 100% against Injection, specifically with Emulated prepares. If possible someone give me an…
-
3
votes1
answer70
viewsHow to display the error coming from Mysql?
I made the code below, and works perfectly, but in case Mysql returns some error, as I will know? I have no idea, someone can help me? The message should return on alert, but I managed to create the…
-
3
votes1
answer88
viewsLong Polling Doesn’t Do Timestamp GET
I picked up this example on the blog http://rberaldo.com.br/server-push-long-polling-php-ios/ Server.php <?php header('Content-type: application/json'); require 'pdo.php'; set_time_limit(0);…
-
3
votes1
answer1465
viewsHow Pdostatement::fetchObject works
I am trying to set the values returned from a query to an object in another class as follows: public function select($id,Cliente $cliente) { $query = "SELECT * FROM compras WHERE id = :id AND email…