[development] node_load using cck fields

Guillaume ! guillaume at resist.ca
Tue Mar 22 16:55:55 UTC 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

That will work in most cases, but if you ever re-use one of the fields
of the date content type with another content type, the field will be
moved to its own table (content_field_date). The safe way is really of
using views, or node_load, but there are obvious scalability issues
with foreach($a = node_load($nid++)), because they are really
independant of the content_type current structure. See
http://groups.drupal.org/node/10129 for more details.

Guillaume !


On 11-03-22 09:47 AM, Steve Edwards wrote:
> Here is the magic incantation:
>
> http://drewish.com/content/2010/06/correctly_accessing_cck_fields_in_sql_queries
>
>
>
Steve
>
> On Mar 22, 2011, at 9:45 AM, larry at garfieldtech.com wrote:
>
>> You can only load nodes in D6 individually by ID. However, you
>> can run raw SQL queries to find nodes meeting certain criteria,
>> then run node_load() on those IDs. I forget the functions off
>> hand but there is a magic incantation to get the right field
>> column info and build a query string yourself.
>>
>> That said, if you're going to be displaying the node(s) then just
>> use Views. It will take much less time and be much more stable,
>> and offer better theming options.
>>
>> In Drupal 7, you'd either use Views or the new EntityFieldQuery.
>>
>> --Larry Garfield
>>
>> On 3/22/11 11:40 AM, Lluís Forns wrote:
>>> I want to load a node using cck fields instead of nid or core
>>> fields.
>>>
>>> Is there a "no-sql" way of doing this? I have read that maybe I
>>> could achieve it using views, but I think it would be an
>>> overkill.
>>>
>>> What I want to achieve is something like this:
>>>
>>> $inscripcio = node_load(array( 'type' => 'inscripcio',
>>> 'field_alumne' => $nid_alumne, 'field_convocatoria' =>
>>> $nid_convocatoria, ));
>>>
>>> any hint?
>>>
>>> If I could get which tables use a cck type and how to join
>>> them, maybe I could code a "generic" way to do this, so if
>>> cck-type is changed, there is no problem.
>>>
>

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBCAAGBQJNiNSbAAoJEIudqlYAGRshIEYP/1A9bbdFIQN0dO1Wc2d3w7QN
sZqEYnFky2cwnU8FAw5gcneDipc6NlnrzhQFMvPGP9f0r5K9RmRpGkre5VoChXuR
Tkw87GyOCKS3NADOOWjI4bicas8m6CDFJHpRSpQRtWgLMne6kNa6P3+3fO0zMXki
4+bKxDaoYj8+bAIRNpOuO2VBE1pW7fG9Bsthte6AkCh2VFtqKvJfJ8VG0qMko2sU
c3QJbgefKpYtwOXroLPvk4aY4wdnTRPRC35gDdR4Y2TgPbPossr7u/l6NGbGB2O7
3Dff8RumNvL13rscpamzjNIHN4f8aDZc4YrtEzLqlsvJOk23aYBygayXiTsir5RH
ICek+tje4St28Awf5LiRS69WqQ8fuyLgu6+3h+sdfNcBvej43KCM9BJOQ7triECx
q8Pl4X//lAem2SP+Toy0tNi/iVUdEsb1Q2XzyxY84MvQZA/rYcxhvjLLh0aJKa7f
cH3FxXzxSNM0G/YhC7V7EEC/UqeTWyhE5HAq2LPqtVj0eML1CHLeSsMqulCzLO2D
t8zUUXBIF1KTPyScATKRK18r4YTzJLIcm+7fQMhkmAJNVVcb+BTUylJelbrYZIyk
avT9VfSlsMrkslD0O/vAQYaeuN5575vVVVnFvK6KEd7wLmLa7fthxqurseYEYCgt
DGTE2d5op/4l3o5/H0D6
=a9c0
-----END PGP SIGNATURE-----



More information about the development mailing list