<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<tt>
<blockquote type="cite">
<pre wrap="">$db_info = content_database_info($field);
$table = $db_info['table'];
</pre>
</blockquote>
Karen,<br>
<br>
You rock! Thanks for enlightening us.<br>
<br>
Take care,<br>
</tt>
<pre class="moz-signature" cols="72">Rob Roy Barreca
Founder and COO
Electronic Insight Corporation
<a class="moz-txt-link-freetext" href="http://www.electronicinsight.com">http://www.electronicinsight.com</a>
<a class="moz-txt-link-abbreviated" href="mailto:rob@electronicinsight.com">rob@electronicinsight.com</a></pre>
<br>
<br>
Karen Stevenson wrote:
<blockquote cite="mid31794.23029.qm@web60017.mail.yahoo.com" type="cite">
<pre wrap="">To find the right table for a field for a SQL query, use the API, like this:
$db_info = content_database_info($field);
$table = $db_info['table'];
That will always return the right table for the requested field.
$field needs to be the complete field array, not just the field name, so if you only have the field name, you would do:
$field = content_fields(my_field_name);
$db_info = content_database_info($field);
$table = $db_info['table'];
content_database_info($field) also contains info about the columns declared by the field so you know what field names to use in a SQL query. It returns an array that looks like:
Array (
[table] => content_type_story
[columns] => Array (
[value] => Array (
[type] => varchar
[length] => 50
[not null] => 1
[default] => ''
[sortable] => 1
[column] => field_phone_value
)
[value2] => Array (
[type] => int
[length] => 10
[unsigned] => 1
[not null] => 1
[default] => 0
[column] => field_phone_type
)
)
)
----- Original Message ----
From: Rob Barreca <a class="moz-txt-link-rfc2396E" href="mailto:rob@electronicinsight.com"><rob@electronicinsight.com></a>
To: <a class="moz-txt-link-abbreviated" href="mailto:development@drupal.org">development@drupal.org</a>
Sent: Thursday, March 22, 2007 7:55:31 PM
Subject: Re: [development] Accessing CCK field data (single, multiple, or shared) from another module
</pre>
<blockquote type="cite">
<pre wrap="">Is there a function for getting the data that you can just give a node
type and a field name and it handles the rest?
</pre>
</blockquote>
<pre wrap=""><!---->This is something I've just run into as well. I have a hardcoded to
query the DB for the multiple field table, but have a TODO in there to
find the right API call.
Rob Roy Barreca
Founder and COO
Electronic Insight Corporation
<a class="moz-txt-link-freetext" href="http://www.electronicinsight.com">http://www.electronicinsight.com</a>
<a class="moz-txt-link-abbreviated" href="mailto:rob@electronicinsight.com">rob@electronicinsight.com</a>
Benjamin Melançon wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Gracious developers, CCK people especially...
I wrote an access control module that works with the node relativity
module to cascade permissions to all nodes lower in a hierarchy. I
hard-coded a query for a userreference field on a custom content type
as one way to give a user access to a node (and its descendants).
In generalizing this, the current stumbling block is the way CCK
stores single instances in the content data table and shared instances
of a field in a separate table.
Is there a function for getting the data that you can just give a node
type and a field name and it handles the rest?
Or is there a place to check what the case is for a particular field?
(Even a "column_exists()" function would do it for me, but haven't
found one in PHP...)
It's being developed in Drupal 5 and fixing this (as well as saving
explicitly permitted users when creating a new node) is all that's
needed for posting the project for general use.
Many thanks,
ben
Agaric Design Collective
Open Source Web Development
<a class="moz-txt-link-freetext" href="http://AgaricDesign.com/">http://AgaricDesign.com/</a>
People Who Give a Damn
building the infrastructure of a network for everyone
<a class="moz-txt-link-freetext" href="http://pwgd.org/">http://pwgd.org/</a>
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
</body>
</html>