This topic is locked

DB API: Data Updated and Truncated without Error

8/27/2021 1:59:09 AM
PHPRunner General questions
A
acpan author

I found out that data was truncated without error message using the DB API. User was updating large JSON data string into a field, and it becomes invalid and throw out error, stopping the page from loading.

I am not sure it is my system problem or a bug. Using PHPRunner v10.05 Build 37251.

Please help to verify it is the same over your end. Many thanks.

Here's the test:

$field1 = varchar (10)

DB:Exec =>

$sql = "UPDATE mytable SET field1 = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX999' ";

$sql = DB::PrepareSQL($sql);
DB::Exec($sql);
echo "Last Error:" .DB::LastError();

=> Result: data truncated, DB::LastError() is empty.


PrepareSQL =>

$_SESSION["field1"] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX999";

$sql = "UPDATE mytable SET field1 = 'session:field1' ";

$sql = DB::PrepareSQL($sql);
DB::Exec($sql);
echo "Last Error:" .DB::LastError();

=> Result: data truncated, DB::LastError() is empty.


DB:Update =>

$data = array();
$keyvalues = array();
$data["field1"] = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX999";
$keyvalues["id"] = 1;
DB::Update("my_table", $data, $keyvalues );
echo "Last Error:" .DB::LastError();

=> Result: data truncated, DB::LastError() is empty.


A
acpan author 8/27/2021

Fyi, I ran the SQL statement on PHPMyAdmin and error was displayed: data too large for the column field1.

on MariaDB version 10.5.11