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.
Locked
narsaw
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?

Thanks,
N

User avatar
pe7er
Joomla! Master
Joomla! Master
Posts: 22117
Joined: Thu Aug 18, 2005 8:55 pm
Location: Nijmegen, The Netherlands
Contact:

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
https://db8.nl - Joomla specialist, Nijmegen, Nederland
Co-developer of d2 Content https://data2site.com/joomla-extensions/d2-content


Locked

Return to “Joomla! Coding 101”