Questions tagged as 'pdo'

2
answers

Check if there is a record in the table

I'm trying to check if there is a record in the mysql table using php, I have the table "slug", and in this table I have "id" and "slug_name", as I do to check if there is already a name in this table, for example: noticia_sobre_o_tempo. how...
asked by 24.07.2017 / 15:17
1
answer

Error 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: : PARAM_STR); $query_delete->ex...
asked by 18.07.2017 / 19:46
1
answer

How to use LIKE in bindValue?

How to use the % operator, for bindValue() , on query below: $sql = 'SELECT * FROM nfe WHERE (cliente LIKE :cliente OR :cliente_ IS NULL)';     
asked by 26.02.2017 / 01:00
1
answer

PDO exec returning false

I'm doing an online course on PHP with PDO and I'm having trouble right away in the first class, with the code: <?php $pdo = new PDO('mysql:host = localhost, dbname = curso_php_oop', 'root', ''); //instanciando a classe do PDO, iniciando c...
asked by 06.03.2017 / 17:38
1
answer

Hexadecimal string cut when inserting with PDO

Good afternoon everyone! I would like some help from you to solve a problem that is happening to me. I have a hexadecimal string containing an image that should be added to the database, when I insert it with the PDO without the bindValue, passi...
asked by 09.01.2017 / 15:15
1
answer

How to confirm the UPDATE with PDO

Do you have a function in the PDO that allows you to check if the UPDATE was successful? Same as method 'lestInsertId ()' is used to check if a new ID was generated in a table with auto increment after an INSERT.     
asked by 13.01.2017 / 01:20
1
answer

Error executing query sql server + php + pdo

Follow 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') is not null DROP TABLE #TabBatidas; SET D...
asked by 01.11.2016 / 22:26
2
answers

Error adding elements in MySQL database with PDO

I'm having the following error while inserting into the database:    Parse error: syntax error, unexpected '{', expecting '(' in /var/www/public/Test/db/add-banco.php on line 18 Line 18 is: } catch { <?php $host = "localhost"...
asked by 31.05.2016 / 15:21
1
answer

How to send variable value into class php?

I've been perfecting secure database connection techniques, and got to the script below. <?php class query_sql { protected static $conect; private function __construct() { $mysql_host = ""; $mysql_base = ""; $mysql_user = "";...
asked by 28.09.2016 / 10:44
1
answer

PDO - Problem with FetchAll

Good afternoon, my friends, my problem today is this. I have the following query: set @row_number = 0; SELECT @row_number:[email protected]_number+1 AS row_number,il.* from itemloja il order by il.LojaId As you can see, there are two that depend. I wan...
asked by 07.01.2016 / 20:54