Page 1 of 1

INSERT into jos_content (content id)

Posted: Tue Aug 26, 2008 8:40 pm
by narsaw
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

Re: INSERT into jos_content (content id)

Posted: Tue Aug 26, 2008 10:06 pm
by pe7er
[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.