By nicroto on
Hi guys,
My question is:
how to load a node that has cck fields, without having nid, whithout db query, only through the api, and the criteria is to match the data in these already mentioned cck fields?
If it's not possible - what remain is...i guess to iterate through all of the nodes (this will have horrible performance). If this is my option anyway I will need to know how to do this, so if someone can support me with some info it will be great!
Best Regards! Cheers!
Comments
_
There's no way to load data without a query-- even the api is going to use queries. Maybe if you describe what you're trying to do we might be able to suggest something.
yes at the lowest level...
Well yeah, but this will happen on the lowest layer before the schema. I want to update the data on my site, which is a mirror of a remote third-party system. So, I am trying to use the most native way to communicate with the Model that I have on the site - not going directly for the data querying the db, but to use whatever the Node API is already providing.
So, basically my task for now is to find a method that will do the querying for me.
Simple example - lets say that I have custom content type called TypeA and it has 2 fields - one text, one user reference and lets say that they make unique couple(by specifying the couple I gotta have only one result). I have 1000 records in the MODEL (the focus is not on the DB). What I want to do is when I have the information of the fields, to be able to find the record corresponding to this data (the couple is unique).
My intention is to stay totally behind the abstraction of the node API and not at one time to call directly the db, and at some other time to use the API.
I hope this explains it!
Thanks in advance!
_
ahhhh... ok I see what you're trying to do. Unfortunately I can't think of a way to do this just with the api, I keep seeing a query with a WHERE clause, lol (though even that you could do with the db api functions). Most of the real api gurus don't hang out in the forums-- you might try http://drupal.org/irc for some advice.
thanks, what about iterating through the node table...
Thank you!
What about iterating through the table of the nodes? Is this possible and if it is, how can I do it?
Thanks!
_
I suppose you could just start at nid = 1 and loop with a node_load-- but that seems really really ugly and very unperformant, lol. Maybe take a look at the http://drupal.org/project/transformations module-- there might be some stuff there you could learn from.
about the $param array in node_load
I see that you can specify an array to match the node without the nid. But can I use specifying the cck's fields data.
If someone can give me at least a hint it will be great!
Come on guys this shouldn't be that hard! :)
One idea here would be to use
One idea here would be to use the Views module to build a query for you. This would be the way I would go if you're looking to output the content in some way but don't want to use a custom query. If you're looking for ways to review a subset of nodes, you could use Views Bulk Operations to create a nice list.
Learn virtually any aspect of Drupal on BuildAModule, where I've recorded over 2200 video tutorials.