views:

187

answers:

3

I have a MySQL table with a column 'full_description' of type 'text'. In that column is a standard lorem ipsum (plus the word END):

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 in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. END

Yet when doing a select on it in php, it only retrieves this much:

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

Here is the php code that retrieves 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 that I get:

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 setting or feature that I'm not aware of that limits the SELECT statements? In MySQL? In PHP mysqli?

Thanks

This is the table structure upon request:

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
A: 

What is the framework you are using? I think this is some default limitation on the datatype TEXT.

By framework I mean the PHP library which access the database:

    $getPosting->bind_param(...);
    $getPosting->execute();
    $getPosting->bind_result(...);
    $getPosting->fetch();
    $getPosting->close();

The above are the functions that comes from some library. And the most probable is that this library has default restrictions for the length of TEXT field.

EDITED:

I have found similar problem with SQL Server and PHP here. They suggest to do like this:

SELECT CAST(F AS TEXT) AS F FROM

Maybe you could do the opposite:

SELECT ..., CAST(full_description AS VARCHAR) FROM postings
Lukasz Lysik
This is the native "mysqli" from php.Those methods are from MySQLi Statement (http://www.php.net/manual/en/class.mysqli-stmt.php).
nute
I've found the description of the bug which is similar. I edited my answer.
Lukasz Lysik
I am using MySQL, not Microsoft SQL. In MySQL, 'text' is much bigger than 'varchar', it's 65,535 characters.
nute
Yes, I know. That is just what I've found. Maybe it will help you some way. That's all I can help.
Lukasz Lysik
A: 

try to initialize an empty string before you fetch and store it in the php.... i had a similar problem where it would only store the first letter of a string, but when i initialized the var before storing to it, it worked

CheeseConQueso
A: 

Instead of using an array to store the results, does it make any difference if you use actual variables i.e. 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 if that makes any difference?

vincebowdren