Hi!
I'm making a web application that would insert node into my Drupal database.
So far I figured that I have to insert records to 'NODE' table and 'NODE_REVISIONS' table.
But if I do that, only users that are logged in can see the created node.
What am I missing?
Thanks.

Comments

tecjam’s picture

If you check the node table you see that you also need to set the status = 1 for it to be published, else it is unpulished and thus hidden.

I'd also make sure you set the 'uid' to the admin (usually uid = 1) and also the 'created' field to time().

nejko15’s picture

I have set the status to 1, that's why I don't understand why it doesn't show up.

nevets’s picture

You should not directly write to those tables, it is better to use node_save().

jaypan’s picture

Yes. When you write directly to the tables, you bypass all the APIs, which ends up in unexpected consequences in the future.

Contact me to contract me for D7 -> D10/11 migrations.

nejko15’s picture

Well I can't do that since I'm developing a separated application that must create story node.
This means I can't use the API :(

nejko15’s picture

I can't. I'm developing a separated application, that means that I can't use the API, doesn't it?

WorldFallz’s picture

you can bootstrap drupal to use the api, but you're probably better off using xmlrpc or the services module to create a proper interface.

In any case, writing directly to the db is definitely not recommended and really just asking for trouble.