Home » Php » php – what is Varien_Db_Ddl_Table::TYPE_TEXT in mysql/magento

php – what is Varien_Db_Ddl_Table::TYPE_TEXT in mysql/magento

Posted by: admin July 12, 2020 Leave a comment

Questions:

I have seen in magento mysql install or upgrade script where they are adding column by using :

$installer->getTable('catalog/eav_attribute'),
    'tooltip',
    array(
        'type'      => Varien_Db_Ddl_Table::TYPE_TEXT,
        'nullable'  => true,
        'comment'   => 'Tooltip'
    )

I Want to know what is Varien_Db_Ddl_Table::TYPE_TEXT? If I want to add the tooltip column manually in mysql table then what should I use in type section? Is it only ‘TEXT‘?

How to&Answers:

Varien_Db_Ddl_Table::TYPE_TEXT is nothing but the type on of the column just like char, varchar,int,tinyint,etc.,

you use anyone type in the following.

const TYPE_BOOLEAN          = 'boolean';
const TYPE_SMALLINT         = 'smallint';
const TYPE_INTEGER          = 'integer';
const TYPE_BIGINT           = 'bigint';
const TYPE_FLOAT            = 'float';
const TYPE_NUMERIC          = 'numeric';
const TYPE_DECIMAL          = 'decimal';
const TYPE_DATE             = 'date';
const TYPE_TIMESTAMP        = 'timestamp'; // Capable to support date-time from 1970 + auto-triggers in some RDBMS
const TYPE_DATETIME         = 'datetime'; // Capable to support long date-time before 1970
const TYPE_TEXT             = 'text';
const TYPE_BLOB             = 'blob'; // Used for back compatibility, when query param can't use statement options
const TYPE_VARBINARY        = 'varbinary'; // A real blob, stored as binary inside DB

// Deprecated column types, support is left only in MySQL adapter.
const TYPE_TINYINT          = 'tinyint';        // Internally converted to TYPE_SMALLINT
const TYPE_CHAR             = 'char';           // Internally converted to TYPE_TEXT
const TYPE_VARCHAR          = 'varchar';        // Internally converted to TYPE_TEXT
const TYPE_LONGVARCHAR      = 'longvarchar';    // Internally converted to TYPE_TEXT
const TYPE_CLOB             = 'cblob';          // Internally converted to TYPE_TEXT
const TYPE_DOUBLE           = 'double';         // Internally converted to TYPE_FLOAT
const TYPE_REAL             = 'real';           // Internally converted to TYPE_FLOAT
const TYPE_TIME             = 'time';           // Internally converted to TYPE_TIMESTAMP
const TYPE_BINARY           = 'binary';         // Internally converted to TYPE_BLOB
const TYPE_LONGVARBINARY    = 'longvarbinary';  // Internally converted to TYPE_BLOB

to get more information refer lib\Varien\Db\Ddl\Table.php

Answer:

I had the same doubt in magento 2, later i found the declaration in table.php in \vendor\magento\framework\DB\Ddl\Table.php