INSERT into jos_content (content id)

Discussion and education for beginner / novice programmers interested in embarking on the development process to take advantage of the extensible nature of the Joomla! CMS.
Joomla! Apprentice
Joomla! Apprentice
Posts: 42
Joined: Thu Jun 07, 2007 4:52 pm

INSERT into jos_content (content id)

Post by narsaw » Tue Aug 26, 2008 8:40 pm

I want to insert an article into my content via a php script. I can write the SQL query but how I assist it a content_id. How do I know the next available content_id to use or know how to choose the next one?

Is there a way of saying INSERT into jos_content (.... .... ...._) use next available ID?


User avatar
Joomla! Master
Joomla! Master
Posts: 23791
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, Netherlands

Re: INSERT into jos_content (content id)

Post by pe7er » Tue Aug 26, 2008 10:06 pm

[MOD note: moving to Joomla! Coding 101]

Yes, the ID field of jos_content is of autoincrement.
If you INSERT a record of information with ID=0 (ID=NULL)
then the database will automatically assign the next free one (* sort of).

* With INSERT an autoincrement value that is stored in the table will be used,
an not the highest ID stored in the table.
If ID=100 & 101 are the two latest articles and ID=101 gets deleted,
then an INSERT with ID=0 will insert the record as ID=102.
Kind Regards,
Peter Martin, Global Moderator - Joomla specialist, Nijmegen, Netherlands
The best website:


Return to “Joomla! Coding 101”