pdo

Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous

别说谁变了你拦得住时间么 提交于 2020-08-26 19:49:10
问题 I am making a simple query but it is not working and I don't know why. I recently started becoming acquainted with PDO connections to databases. Here is the code : The Connections is : define("HOST","localhost"); define("USER","root"); define("PASS","password"); define("BASE","portugalforcedb"); try{ $conexao = 'mysql:host='.HOST.';dbname='.BASE; $connect = new PDO($conexao, USER, PASS); $connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }catch(PDOException $erro){ echo $erro-

Insert empty value using Bindparam without error Incorrect Integer value

天大地大妈咪最大 提交于 2020-08-20 12:02:34
问题 I want to insert some data into my MySql table using PDO. If it's not empty it will have Integer datatype so i use PDO::PARAM_INT, but the problem is this data is not required so sometimes it's empty. It make me have an error: PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value. So is it anyway I can pass this empty value variable into my database without having error when it have empty value? here's my code snippet: $stmt = $db->prepare("INSERT INTO table (column)