By HardikBadani on
Hello friends,
I am trying to get all fields of a content type to generate one report.
But when i try to fetch it all it doesn't come in sequence which is maintain in the content type.
Can anyone help me that how can i get all fields sequentially as mentioned in the content type...?
Thank You in Advance...!!!
Comments
'ORDER BY nid ASC'.
'ORDER BY nid ASC'.
Contact me to contract me for D7 -> D10/11 migrations.
Thanks for reply 'ORDER BY
Thanks for reply
'ORDER BY nid ASC'. cant be worked...
Bcoz i am fetching all fields from content_node_field_instance table where nid is not there...
As i have tried using order by weight but then also some fields not come in sequentially....
Just use another field
Just use the order by clause with whatever field you find is appropriate.
Clear the Question
I think still all of you are not getting my question clearly....
Let me explain it again....
I want every fields of content type in sequence as i created in content type from admin.
To get all content type i have written query on the content_node_field_instance table, where field_name is primary key.
So cant apply order by on nid , because nid field is not in this table...
To get all fields in sequentially i have written query using order by weight...
Now...When i got result of this query...Some fields still not getting sequentially...
So my question is : Is there any another way to get all fields of any content type in sequentially...
or should i do any modification in above method...?
Hope Everyone clear now...waiting for answer...Thank You...!
If you haven't saved some
If you haven't saved some kind of data that increases with each item, then there is no way to get it sequentially. So either you need a row ID, which it sounds like you don't have one, or you need a creation date, or something else that is increasing with each row.
If you don't have one of these, then there is no way to get your data sequentially.
Contact me to contract me for D7 -> D10/11 migrations.
Not Exactly
As i mentioned earlier that in content_node_field_instance table there is no any primary key id...so the option using rowid is not possible....
Next is creation date - we cant use it because if i have created one field in content type lastly which has highest created time...now if i moved that field at top in my content type and save it...
So as per created time its position is last but as i want its position first...
So this is also not possible.....
If u have any another solution please give me....otherwise i have to fetch all them manually...
Waiting with hope....Thank You...!!
Do you have a column in your
Do you have a column in your table that has sequential data? Anything that will increase as nodes are completed.
Also, you are referring to the data you are recovering as nodes. But your data obviously isn't part of the node table - so how is it relating to the node table? are you doing this purely by relating the titles? If so, then you should rebuild your module, as titles are not unique, and this is going to screw things up down the line.
Contact me to contract me for D7 -> D10/11 migrations.
Are the tables related
Hi,
Are the tables related? if so, just issue an sql join. Join the tables till your query includes the field you need to sort on. http://www.w3schools.com/sql/sql_join.asp
Drupal uses either Mysql or Postgres database engines. Both of these database implementations are "relational databases". You query related tables via an SQL join.
I'm interested in the same thing.
Hi All,
I'm interested in the same thing, and I think I can see where people are not understanding the original question.
The main point is that we're looking for the FIELDS on a content type.
This must be possible, because core Drupal does it every time it assembles the "manage fields" page for a given content type.
We want to retrieve all the fields on a content type in that same order (edit: the same order the core gets them in on the 'manage fields' page for that content type.)
One trick that might help is to get a logging system to record the exact MySQL query that core is doing when it assembles that page.
Good Luck. I'll report back if I find it.
Christian Nally - B.C., Canada - http://sticksallison.com
Could it be that you can get
Could it be that you can get the list of fields from this function?
http://drupalcontrib.org/api/function/content_types/6
Part of what it returns is a list of fields.
(This is what Views Bulk Operations does in its "modify field values" action).
Christian Nally - B.C., Canada - http://sticksallison.com
CCK field order by content type
This query, or some variation of it, may be what you're looking for:
SELECT field_name, type_name, weight, label FROM {content_node_field_instance} ORDER BY type_name, weight;