[development] node_load using cck fields

Lluís Forns enboig at gmail.com
Wed Mar 23 08:48:48 UTC 2011


Sorry, I didn't explain myself. I have read the article and I am
writing a "query builder" that loads a node matching received $params.

My concert right now is that following the example
content_database_info should return something like:
array(2) {
  ["table"]=>
  string(17) "content_type_date"
  ["columns"]=>
  array(2) {
    ["value"]=>
    array(6) {
      ["type"]=>
      string(7) "varchar"
      ["length"]=>
      int(20)
      ["not null"]=>
      bool(false)
      ["sortable"]=>
      bool(true)
      ["views"]=>
      bool(true)
      ["column"]=>
      string(16) "field_date_value"
    }
    ["value2"]=>
    array(6) {
      ["type"]=>
      string(7) "varchar"
      ["length"]=>
      int(20)
      ["not null"]=>
      bool(false)
      ["sortable"]=>
      bool(true)
      ["views"]=>
      bool(false)
      ["column"]=>
      string(17) "field_date_value2"
    }
  }
}


but in my case it returns:
field_alumne => Array
(
    [table] => content_field_alumne
    [columns] => Array
        (
            [nid] => Array
                (
                    [type] => int
                    [unsigned] => 1
                    [not null] =>
                    [index] => 1
                    [column] => field_alumne_nid
                )

        )

)

I assume the difference is because I access a related node and not data itself.

2011/3/22 Michael Prasuhn <mike at mikeyp.net>:
> It's pretty clear that you did not read the linked article. It is perfectly
> safe to use CCKs API to find out what tables a field's data is stored in.
> How do you think that Views is able to get at the correct table?
>
> -Mike
>
> Guillaume ! wrote:
>>
>> 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.
>>
>> 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
>>>
>
> --
> __________________
> Michael Prasuhn
> 503.512.0822 office
> mike at mikeyp.net
> http://mikeyp.net
>



-- 
*Les normes hi són perquè hi pensis abans de saltar-te-les
*La vida és com una taronja, què esperes a exprimir-la?
*Si creus que l'educació és cara, prova la ignorància.
*La vida és com una moneda, la pots gastar en el que vulguis però
només una vegada.
*Abans d'imprimir aquest missatge, pensa en el medi ambient.


More information about the development mailing list