hh2hh 发表于 2011-3-17 17:53:24

求助, sql server 2000的数据库无法完整取出超过127个字符的字串

今天又遇到一个问题, 我是用sql server 2000的数据, 其中有个字段是限制3000字符(3000)。我发现存储的时候能成功把数据存入,但是取出数据的时候只能取出127个字符,后面的内容全部被截断。请各位帮忙看看是什么原因,谢谢啦。

以下是我取出数据的模型方法:


    function get_by_id($id)
    {
      $row = array();
      
      $this->db->from('UploadImg');
      $this->db->where('id', $id);
      $query = $this->db->get();
      
      if($query->num_rows() == 1)
      {
            $row = $query->row_array();
      }
      
//echo $row['Description'];//在这里已经是只有127个字符了

      return $row;
    }

hh2hh 发表于 2011-3-17 18:02:43

刚才用这个帖子的方法试了一下, 问题依旧
http://codeigniter.org.cn/forums/viewthread.php?tid=170&rpid=969&ordertype=0&page=1&styleid=1

hh2hh 发表于 2011-3-17 18:30:27

刚才查到mssql的这个解决方法, 似乎可行http://nan3120.blog.163.com/blog/static/1729002272011021101641421/

我改成如下代码,可惜运行出错, 有人能帮忙看看这个sql应该怎么写吗?谢谢

    function get_by_id($id)
    {
      $row = array();
      $this->db->select('id,cast(Description as text)',FALSE);
      $this->db->from('UploadImg');
      $this->db->where('id', $id);
      $query = $this->db->get();
      
      if($query->num_rows() == 1)
      {
            $row = $query->row_array();
      }
      
//echo $row['Description'];//取不到这个值

      return $row;
    }

hh2hh 发表于 2011-3-17 19:38:04

自己搞定了. 原来是语法上的小问题. 这样就行了:select('id,cast(Description as text) as Description',FALSE);

function get_by_id($id)
    {
      $row = array();
      $this->db->select('id,cast(Description as text) as Description',FALSE);
      $this->db->from('UploadImg');
      $this->db->where('id', $id);
      $query = $this->db->get();
      
      if($query->num_rows() == 1)
      {
            $row = $query->row_array();
      }

      return $row;
    }
页: [1]
查看完整版本: 求助, sql server 2000的数据库无法完整取出超过127个字符的字串