How to write query using JDatabaseQuery in Joomla 1.7?

3.5k views Asked by At

I have a following table and I want to know how to write the inset query using JDatabaseQuery in Joomla.

jos_esolutions_movies - table name
id, name, description, status - field names
1 , 'ABC' , 'ABC description', 0 - example values
3

There are 3 answers

0
Gaurav On BEST ANSWER
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->insert('#__tablename');
$query->set("field1='values1', field2='values2'");
$db->setQuery($query);
$db->query();
1
jogesh_pi On

the following link will help you to create a joomla database query http://docs.joomla.org/How_to_use_the_database_classes_in_your_script

1
AudioBubble On
$db =& JFactory::getDBO();
$query = "insert into #__esolutions_movies (id, name, description, status) values(1 , 'ABC' , 'ABC description', 0)";
$db->setQuery($query);
$db->query();