php - How do I get the complete string of a BLOB using PDO? -
php - How do I get the complete string of a BLOB using PDO? -
i'm creating c# php info connector allow standardized connection web server host info database c# winform application. working 1 little exception.
the basic of utilize this.
c# sends aes encrypted command server. server parses command , performs sql query , returns aes encrypted string. string converted datatable in c#.
when sql contains column blob i'm getting little part of total data. seems field beingness limited first 2792 bytes.
is there setting preventing total contents of blob returned?
i'm not sure if helpful, here code work.
$dataconnection = new pdo('mysql:host=10.10.100.102;dbname=jmadata', "root", "nbtis01"); $dataconnection->setattribute(pdo::attr_errmode, pdo::errmode_exception); if (isset($parameters['sqlquery'])) { // default list $sqlquery = $parameters['sqlquery']; unset($parameters['sqlquery']); } if (isset($parameters['limitoverride'])) { if (!strpos(strtoupper($sqlquery), "limit")) $sqlquery = rtrim($sqlquery, ';') . " limit " . $parameters['limitoverride']; unset($parameters['limitoverride']); } $queryparams = array(); foreach ($parameters $key => $value) if ($key !== '') $queryparams[$key] = $value; $query = $dataconnection->prepare($sqlquery); $query->execute($queryparams); $returnarray = $query->fetchall(pdo::fetch_assoc); if (!$returnarray) $returnarray[0] = array("noresults" => "");
edit -- answer
i found issue. problem had nil pdo, php or mysql. taking blob info , doing base64 before putting in array, split characters using build result string converted datatable in c# used non-printable characters , binary info string might have included these characters. issue when doing convert in c# original string convert byte array. using system.text.encoding.ascii.getstring convert base64 byte array original string. working on binary info blob fields.
the suggestion might terminating character made me find it. 1 time base64 converted string using ascii there turning terminator , stopping convert @ point. 1 time found changed system.text.encoding.default.getstring , works perfect.
posted reply in case else might trying , having same issue.
more details in edit of question.
changed system.text.encoding.ascii.getstring system.text.encoding.default.getstring , issue resolved.
thank crunch pointing me in right direction find solution.
php sql pdo
Comments
Post a Comment