Некоторые части моего запроса кодируются разными словами [дубликат] ⇐ Php
Некоторые части моего запроса кодируются разными словами [дубликат]
So I have this PHP function that contains a query to select data from postgresql database
public function checkEkspedisi2($resi_no, $shipper) { $return = array(); $conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $sql = "SELECT resi_no FROM t_vbak WHERE resi_no = '$resi_no' "; if ($shipper == "J&T") { $sql .= " AND (UPPER(REPLACE(shipper,' ','')) LIKE ('%" . strtoupper(trim($shipper)) . "%')) AND (UPPER(REPLACE(shipper,' ','')) NOT LIKE UPPER('%Cargo%')) "; } else { $sql .= " AND UPPER(REPLACE(shipper,' ','')) LIKE('%" . strtoupper(trim($shipper)) . "%') "; } echo $sql; die(); $stmt = $conn->prepare($sql); if ($stmt->execute()) { while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $return[] = $row; } } $stmt = null; $conn = null; return $return; } This specific part below change from UPPER('%Cargo%') to UPPER('Êrgo%') when I echo the query.
My code :
AND (UPPER(REPLACE(shipper,' ','')) LIKE ('%" . strtoupper(trim($shipper)) . "%')) AND (UPPER(REPLACE(shipper,' ','')) NOT LIKE UPPER('%Cargo%')) echo result :
AND (UPPER(REPLACE(shipper,' ','')) LIKE ('%J&T%')) AND (UPPER(REPLACE(shipper,' ','')) LIKE UPPER('Êrgo%')) I've tried wrapping it using urlencode function in php but the result of the query is different from the database. When i manually query it from pgAdmin the result is correct, but the result from the PHP function (using urlencode) returns a different value (wrong)
Источник: https://stackoverflow.com/questions/781 ... rent-words
So I have this PHP function that contains a query to select data from postgresql database
public function checkEkspedisi2($resi_no, $shipper) { $return = array(); $conn = new PDO(DB_DSN, DB_USERNAME, DB_PASSWORD); $sql = "SELECT resi_no FROM t_vbak WHERE resi_no = '$resi_no' "; if ($shipper == "J&T") { $sql .= " AND (UPPER(REPLACE(shipper,' ','')) LIKE ('%" . strtoupper(trim($shipper)) . "%')) AND (UPPER(REPLACE(shipper,' ','')) NOT LIKE UPPER('%Cargo%')) "; } else { $sql .= " AND UPPER(REPLACE(shipper,' ','')) LIKE('%" . strtoupper(trim($shipper)) . "%') "; } echo $sql; die(); $stmt = $conn->prepare($sql); if ($stmt->execute()) { while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { $return[] = $row; } } $stmt = null; $conn = null; return $return; } This specific part below change from UPPER('%Cargo%') to UPPER('Êrgo%') when I echo the query.
My code :
AND (UPPER(REPLACE(shipper,' ','')) LIKE ('%" . strtoupper(trim($shipper)) . "%')) AND (UPPER(REPLACE(shipper,' ','')) NOT LIKE UPPER('%Cargo%')) echo result :
AND (UPPER(REPLACE(shipper,' ','')) LIKE ('%J&T%')) AND (UPPER(REPLACE(shipper,' ','')) LIKE UPPER('Êrgo%')) I've tried wrapping it using urlencode function in php but the result of the query is different from the database. When i manually query it from pgAdmin the result is correct, but the result from the PHP function (using urlencode) returns a different value (wrong)
Источник: https://stackoverflow.com/questions/781 ... rent-words
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение