PHP MySQL SELECT text truncated
I have a MySQL table with a 'full_description' column of type 'text'. This column contains the standard lorem ipsum (plus the word END):
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod time incididunt ut labore et dolore magna aliqua. Ut enim ad minim veins, trainings quis nostrud ullamco labis nisi ut aliquip ex ea commo. Duis aute irure dolor at reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat is irrelevant, sunt in culpa qui officia deserunt mollit anim id est laborum. END
However, when you do a selection on it in php, it only fetches that a lot:
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod time incididunt ut labore et dolore magna aliqua. Ut enim ad minim veins, trainings quis nostrud ullamco labis nisi ut aliquip ex ea commo. Duis aute irure dolor i
Here is the php code that fetches it:
function getPostingDetails($posting_id){
$getPosting = $this->PLAST->prepare('SELECT posting_id, poster_id, title, short_description, full_description FROM postings WHERE posting_id=?');
$getPosting->bind_param('i',$posting_id);
$getPosting->execute();
$getPosting->bind_result($row['posting_id'],$row['poster_id'],$row['title'],$row['short_description'],$row['full_description']);
$getPosting->fetch();
$getPosting->close();
return $row;
}
This is the array I am getting:
Array ( [posting_id] => 1 [poster_id] => 1 [title] => Test 1 [short_description] => This is a short description. [full_description] => Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor i )
The rest of the fields are fine. What am I doing wrong? Or is there a parameter or function that I am not aware of that limits the SELECT expressions? In MySQL? In PHP mysqli?
thank
This is the table structure as requested:
CREATE TABLE `postings` (
`posting_id` int(11) NOT NULL AUTO_INCREMENT,
`poster_id` int(11) NOT NULL,
`title` tinytext NOT NULL,
`short_description` tinytext NOT NULL,
`full_description` text NOT NULL,
PRIMARY KEY (`posting_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
source to share
What structure are you using? I think this is the default constraint for TATT datatype.
By structure, I mean the PHP library that accesses the database:
$getPosting->bind_param(...); $getPosting->execute(); $getPosting->bind_result(...); $getPosting->fetch(); $getPosting->close();
The above are functions that come from some library. And it is most likely that this library has a default limit on the length of the TEXT field.
Editorial staff:
I found a similar issue with SQL Server and PHP here . They suggest doing the following:
SELECT CAST(F AS TEXT) AS F FROM
Perhaps you could do the opposite:
SELECT ..., CAST(full_description AS VARCHAR) FROM postings
source to share
Instead of using an array to store the results, does it make any difference if you are using actual variables, that is, replace this: $getPosting->bind_result($row['posting_id'],$row['poster_id'],$row['title'],$row['short_description'],$row['full_description']);
with this:
$getPosting->bind_result($posting_id,$poster_id,$title,$short_description,$full_description);
See, does it matter?
source to share