Updating dates in an update query

15-Jun-2017 14:27

Before we go into more details discussion the DELETE command, let's insert some sample data into the movies table to work with.INSERT INTO `movies` (`title`, `director`, `year_released`, `category_id`) VALUES ('The Great Dictator', 'Chalie Chaplie', 1920, 7); INSERT INTO `movies` (`title`, `director`, `category_id`) VALUES ('sample movie', 'Anonymous', 8); INSERT INTO movies (`title`, `director`, `year_released`, `category_id`) VALUES ('movie 3', 'John Brown', 1920, 8); Let's suppose that the Myflix video library no longer wishes to be renting out "The Great Dictator" to its members and they want it removed from the database.To obtain a new instance of the JDatabase Query class we use the JDatabase Driver get Query method: takes an optional argument, $new, which can be true or false (the default being false).To query our data source we can call a number of JDatabase Query methods; these methods encapsulate the data source's query language (in most cases SQL), hiding query-specific syntax from the developer and increasing the portability of the developer's source code.Note that unlike Insert queries, Update Query::fields() only accepts an associative array.Also, the order of fields in the array and the order in which methods are called are irrelevant.

Using the Joomla database layer ensures a maximum of compatibility and flexibility for your extension.It can also be used to update one or more record in one go.The ELSE title is very important, otherwise you will overwrite the rest of the table with NULL.Joomla's database querying has changed since the new Joomla Framework was introduced "query chaining" is now the recommended method for building database queries (although string queries are still supported).Query chaining refers to a method of connecting a number of methods, one after the other, with each method returning an object that can support the next method, improving readability and simplifying code.

Using the Joomla database layer ensures a maximum of compatibility and flexibility for your extension.

It can also be used to update one or more record in one go.

The ELSE title is very important, otherwise you will overwrite the rest of the table with NULL.

Joomla's database querying has changed since the new Joomla Framework was introduced "query chaining" is now the recommended method for building database queries (although string queries are still supported).

Query chaining refers to a method of connecting a number of methods, one after the other, with each method returning an object that can support the next method, improving readability and simplifying code.

Update queries must always use a query builder object.