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. -- *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.
Hi Lluís, EntityFieldQuery is what you are after: http://api.scratch.drupal.org/api/drupal/includes--entity.inc/class/EntityFi... http://drupal.org/node/916776 Regards Steven Jones ComputerMinds ltd - Perfect Drupal Websites Phone : 024 7666 7277 Mobile : 07702 131 576 Twitter : darthsteven http://www.computerminds.co.uk On 22 March 2011 16:40, Lluís Forns <enboig@gmail.com> 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.
-- *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.
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.
Here is the magic incantation: http://drewish.com/content/2010/06/correctly_accessing_cck_fields_in_sql_que... Steve On Mar 22, 2011, at 9:45 AM, larry@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 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_que...
Steve
On Mar 22, 2011, at 9:45 AM, larry@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-----
Using <?php $field = content_fields('field_date'); $db_info = content_database_info($field); ?> I will try to build a query which gets if it need to add joins, etc...; so if database schema is changed it will also change. 2011/3/22 Guillaume ! <guillaume@resist.ca>:
-----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_que...
Steve
On Mar 22, 2011, at 9:45 AM, larry@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-----
-- *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.
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_que...
-- __________________ Michael Prasuhn 503.512.0822 office mike@mikeyp.net http://mikeyp.net
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@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_que...
-- __________________ Michael Prasuhn 503.512.0822 office mike@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.
I finished my function, I just added support for nodereference fields because this is what I want; maybe when I need more support I will add it. I post the code here, any comment is wellcome. function node_load_cck($param = array()) { if (is_numeric($param)) { return node_load($param); } $select = "SELECT n.nid FROM {node} n "; $join = ''; $where = ' WHERE 1 '; $data = array(); //contains array( 'table' => 'alias'); $tables = array(); $i = 0; foreach($param as $field_code => $field_value) { $data[] = $field_value; if (substr($field_code, 0, 6) == 'field_') { $field = content_fields($field_code); switch ($field['type']) { case 'nodereference': $db_info = content_database_info($field); if (!in_array($db_info['table'], $tables)) { $tables[$db_info['table']] = 't'.$i; $join .= ' LEFT JOIN {'.$db_info['table'].'} '.'t'.$i.' ON n.vid = '.'t'.$i.'.'.vid.' '; } $where .= " AND ".$tables[$db_info['table']].'.'.$db_info['columns']['nid']['column']." = '%s' "; break; default: //TODO } } else { $where .= " AND n.".$field_code." = '%s' "; } $i++; } $sql = $select . ' ' . $join . ' ' . $where; $nid = db_result(db_query($sql, $data)); $node = node_load($nid); return $node; } 2011/3/23 Lluís Forns <enboig@gmail.com>:
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@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_que...
-- __________________ Michael Prasuhn 503.512.0822 office mike@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.
-- *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.
Searching more I found http://drupal.org/node/360541 which was nearly what I was looking for. I changed that function because it was returning a "node"; so now it returns an array of nids and then I can use node_load() to load them (in my case just one). It also uses db_rewrite_sql() to ensure you can only load nodes accessible to you. The final function is: function _content_node_loads($param = NULL) { if (!is_array($param)) { return FALSE; } $arguments = array(); $cck_tables = array(); $cck_cond = array(); $cond = array(); $i = 1; foreach ($param as $key => $value) { if (substr($key, 0, 6) != 'field_') { $cond[] = 'n.'. db_escape_table($key) ." = '%s'"; $arguments[] = $value; } else{ $db_info = content_database_info(content_fields($key)); // If the field is from another table, increment sequence if(!isset($cck_tables[$db_info['table']])){ $cck_tables[$db_info['table']] = 'cck'. $i; } $i++; if($db_info['columns']['nid']){ // For nodereference fields $cck_cond[] = $cck_tables[$db_info['table']] .'.'. db_escape_table($db_info['columns']['nid']['column']) ." = '%s'"; } else if ($db_info['columns']['value']) { $cck_cond[] = $cck_tables[$db_info['table']] .'.'. db_escape_table($db_info['columns']['value']['column']) ." = '%s'"; } else if ($db_info['columns']['uid']) { $cck_cond[] = $cck_tables[$db_info['table']] .'.'. db_escape_table($db_info['columns']['uid']['column']) ." = '%s'"; }else if ($db_info['columns'][$key]['column']) { $cck_cond[] = $cck_tables[$db_info['table']] .'.'. db_escape_table($db_info['columns'][$key]['column']) ." = '%s'"; } $arguments[] = $value; } } $cond = (!empty($cond) ? implode(' AND ', $cond) : '' ); if (!empty($cck_cond)) { $cond .= (!empty($cond) ? ' AND ' : ''). implode(' AND ', $cck_cond); foreach ($cck_tables as $table => $nick) { $cck_join .= ' INNER JOIN {'. $table .'} '. $nick .' ON '. $nick .'.nid = n.nid'; } } $sql = "SELECT n.nid FROM {node} n ".$cck_join." WHERE ".$cond; $res = db_query(db_rewrite_sql($sql), $param); $nids = array(); while ($nid = db_result($res)) { $nids[$nid] = $nid; } return (empty($nids) ? FALSE : $nids); } 2011/3/23 Lluís Forns <enboig@gmail.com>:
I finished my function, I just added support for nodereference fields because this is what I want; maybe when I need more support I will add it. I post the code here, any comment is wellcome.
function node_load_cck($param = array()) { if (is_numeric($param)) { return node_load($param); } $select = "SELECT n.nid FROM {node} n "; $join = ''; $where = ' WHERE 1 '; $data = array(); //contains array( 'table' => 'alias'); $tables = array(); $i = 0; foreach($param as $field_code => $field_value) { $data[] = $field_value; if (substr($field_code, 0, 6) == 'field_') { $field = content_fields($field_code); switch ($field['type']) { case 'nodereference': $db_info = content_database_info($field); if (!in_array($db_info['table'], $tables)) { $tables[$db_info['table']] = 't'.$i; $join .= ' LEFT JOIN {'.$db_info['table'].'} '.'t'.$i.' ON n.vid = '.'t'.$i.'.'.vid.' '; } $where .= " AND ".$tables[$db_info['table']].'.'.$db_info['columns']['nid']['column']." = '%s' "; break; default: //TODO } } else { $where .= " AND n.".$field_code." = '%s' "; } $i++; } $sql = $select . ' ' . $join . ' ' . $where; $nid = db_result(db_query($sql, $data)); $node = node_load($nid); return $node; }
2011/3/23 Lluís Forns <enboig@gmail.com>:
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@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_que...
-- __________________ Michael Prasuhn 503.512.0822 office mike@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.
-- *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.
-- *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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 D6: Not really. You can node_load (with reset=1) on all of the nodes and check them. Or use a view object, that feels like an overkill, but its way more configurable. On 11-03-22 09: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/ iQIcBAEBCAAGBQJNiNKjAAoJEIudqlYAGRshkYwQALRZDpQbLdcjqc50gDw/b2jB r6LWyV2zJuNAkPNlwd1iDn2d7ahazUWYAfANRuJh0fzk01uTySxn9T2JmxCmMnbA BFRHtAUloAWeRug0IZP3I2wIfLJGhQBBheyjbOe3Cjd+IKT76NiXI7kr/a6glf2k Zo9rwO6jYZZVc66nkfH1zYQBEqaYYH8pKYB8m0VRH3VTpFJ/k75KdPzX3Q0yXSIT WvZfRqnRkgr2CFvDacFRgk+ICEsB8V/ZkfPNr67wcEHjG/ETVSnatzquBhsxThgO m93sgh7eIuIj5cg6knUPUmht68ETJD0i8N5Zu35JPZpoOLwzkzYU7hQt3YEohpvS bdOZ99Kd4ePlekCpr2xz/qcTl1WuixHcAirgL64QwnGCmzzISTaUWtJdQzOHsNVx oEAWpagHhECVJqZ8dXB96u2jkRtpz3XA0nIGRiZPTP+pQfEOPpH9pOYBnxd5qiL3 nA7fXjcPwaskOoHRhwUbvxzb3Df+bCpYUXGHOHNcpc61uqGKo+wVz7PmqikjZx1p myITa2htRAzp0kK7IsIMOdxmJL0dk6y3HjJRdyYsyFjgVMwP4KhhhHlRaEDvOzgG RKwqOaKNSjs1ZlT984WHA65nqdW4L7rmW4N6cu6Pf4Ej76TdC157e0D/3t46I8zm gErz+Uo5zL6jOEII/ioO =JxdM -----END PGP SIGNATURE-----
participants (6)
-
Guillaume ! -
larry@garfieldtech.com -
Lluís Forns -
Michael Prasuhn -
Steve Edwards -
Steven Jones