Jump to content

Max character length in text field


Karl_T
 Share

Recommended Posts

I would like to save very long string to a text field. My case is that I am saving canvas serialized data into text field for saving as state. However, the the text link cannot excceed certain length which is around 66535 something even though I set the field's max length as 0. What I can do to release the limit? Thanks.

Link to comment
Share on other sites

Rather than edit the DB for an existing field, you could make a simple fieldtype module that extends FieldtypeTextarea:

<?php
class FieldtypeLongTextarea extends FieldtypeTextarea {

    /**
     * Module information
     */
    public static function getModuleInfo() {
        return array(
            'title' => 'Long Textarea',
            'version' => 1,
            'summary' => 'Field that stores multiple lines of text in a MySQL LONGTEXT column type.',
        );
    }

    /**
     * Get database schema used by the Field
     *
     * @param Field $field
     * @return array
     *
     */
    public function getDatabaseSchema(Field $field) {
        $schema = parent::getDatabaseSchema($field);
        $schema['data'] = 'longtext NOT NULL';
        $schema['keys']['data'] = 'FULLTEXT KEY data (data)';
        return $schema;
    }

}

 

  • Like 3
  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...