Re: Re: DataObject, querying string bigger than 255 chars
| From: | Arthur Yarwood | Date: | Mon, 07 Feb 2005 16:41:01 +0000 |
| Subject: | Re: Re: DataObject, querying string bigger than 255 chars | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-17425@lists.php.net to get a copy of this message | ||
Your right. A quick gander in the php docs and I found this comment:-
Page: http://www.php.net/manual/en/ref.mssql.php
|"Note to Win32 Users: Due to a limitation in the underlying API used by PHP (MS DbLib C API), the length of VARCHAR fields is limited to 255. If you need to store more data, use a TEXT field instead.
SQL Server natively supports VARCHAR up to 8000 characters. Note that TEXT fields have substantially poorer performance (and are much more limited) than VARCHAR so you may want to design your databases accordingly..."
So I've converted all my big string fields to 'text' data type. Re-gen'd my DataObject classes. Now the column is defined like this:-
var $Notes; // text(4096) Which makes me wonder if the unerlying interface only supports string under 4096 long...Eitherway it works and 4096 should be big enough for my needs. | Arthur. Alan Knowles wrote:
check with the database drivers / db backend - PEAR:DB is reporting that the column is 255 chars (probabably due to the php driver reporting that.) - I'm guessing it's also the driver that is trimming data as well. Someone with MS SQL may know more about it. Regards Alan Arthur Yarwood wrote:I'm using DB_DataObject (ver 1.7.2), with M$ SQL Server 2000. I'm having problems querying a string column bigger than 255 chars. The column is of varchar type and 1024 chars in size. However when I query a row, I only get the first 255 chars of the column. Updating seems to work ok though, it can save strings bigger than 255 chars. When I autogen the DataObject class looks like this:- (I've snipped out all but two column). class DataObjects_SongEvaluation extends DB_DataObject { ###START_AUTOCODE /* the code below is auto generated do not remove the above tag */var $__table = 'SongEvaluation'; // table name var $ID; // int(4) not_null auto_increment... <snip> ...var $Notes; // char(255) ... <snip> .../* Static get */ function staticGet($k,$v=NULL) { return DB_DataObject::staticGet('DataObjects_SongEvaluation',$k,$v); } /* the code above is auto generated do not remove the tag below */ ###END_AUTOCODE } Don't why it thinks it is only 255. Did try manually changing the comment, to no effect. I query the row, using by an id passed into the webpage, like so:- $SongID = 0; $seDO = DB_DataObject::factory('SongEvaluation'); if ( isset($_REQUEST['SongID']) ) { $SongID = $_REQUEST['SongID']; $seDO->get( $SongID ); } Then a print_r($seDO); will reveal that only the first 255 chars have been queried from the database. What am I doing wrong? Thanks, Arthur