shadowbudz
shadowbudz

Reputation: 241

How to insert column in Joomla table

i have a problem in inserting a varchar in column in a table in joomla. I know that there is a syntax

ALTER TABLE joom_virtuemart_categories_en_gb ADD short_desc varchar(1200);

But how do i do it in joomla query? Here is my code.

Hope you can help me. thanks

$db = JFactory::getDbo();
$query = $db->getQuery(true);

$query->insert('short_desc')
	->from('joom_virtuemart_categories_en_gb');


$db->setQuery($query);
$results = $db->loadObjectList();

Upvotes: 3

Views: 1138

Answers (1)

Nehal
Nehal

Reputation: 1523

There's no special syntax for alter command, you need to use that as you use for core php :

 <?php
    $db = JFactory::getDbo();
    $query='ALTER TABLE `#__virtuemart_categories_en_gb` ADD `short_desc` varchar(1200)';
    $db->setQuery($query);
    $result = $db->query();
 ?>

Upvotes: 3

Related Questions