[support] sql query and other

Simone Dal Maso simone.dalmaso at juvox.it
Fri Dec 12 10:23:33 UTC 2008


Shai,
really, thank you very much.
Your message was detailed and I forward it to a friend of mine and with 2 
query we solved the problem.
Still thanks.
bye.

----- Original Message ----- 
From: "Shai Gluskin" <shai at content2zero.com>
To: <support at drupal.org>
Sent: Wednesday, December 10, 2008 5:14 PM
Subject: Re: [support] sql query and other


> Simone,
>
> My opinion (which is not authoritative) regarding the easiest strategy to
> solve your problem would be to write a query which would select the 
> contents
> of the teaser field and put it into a variable (remember to include the
> write the "WHERE" clause in the query to only pull the nodes you want to
> affect). Then you write another query which replaces the current content 
> of
> the body field with the content of the teaser field that is in the 
> variable
> that you stored.
>
> The snippet you write can be run using Devel module's "drupal execute" 
> tool.
> That way you would avoid having to write a module to implement a one-time
> task.
>
> f you are not experienced writing code like this I'll give you this
> unsolicited advice to help get you started...
>
> The first thing you need to do is to write your SELECT query and make sure
> it works and pulls in only the right rows from the node revisions table. 
> The
> good part about this part is that you don't need to mess with PHP at this
> stage. You just query the database directly, using a tool like phpMyAdmin 
> or
> the command line, whatever. When doing SELECT queries your blood preassure
> stays low because SELECT queries don't change the DB. [But still, back up
> the db before you even start, because you might forget after you start
> working.]
>
> Next you write the query for replacing the body field with the teaser 
> field
> contents. Again, no PHP, you just copy teaser contents from one node and
> hard code that into your query. (Be careful to add a clause "WHERE nid=25"
> --- where "25" is the node id where you copied the teaser from. This part
> raises your blood pressure a bit, since the test query actually does 
> change
> the database. But by cleary limiting the query to one row, you keep things
> under good control.)
>
> Once you have tested that the second query works, you can build the PHP
> snippet to cycle through each record creating new body fields using the
> variable which will have stored the results of the first query.
>
> By having tested that your queries are correct first, you'll have much
> greater confidence building and then debugging the PHP snippet.
>
> As an alternative to this whole approach to your problem, you might be 
> able
> to write complicated custom views which would sometimes display the teaser
> field and sometimes display the full node based on taxonomy, url strings, 
> or
> whatever. But I think it is cleaner to simply change the body field by
> putting in the data there that you actually want.
>
> Good luck, report back,
>
> Shai
>
> On Wed, Dec 10, 2008 at 5:10 AM, Simone Dal Maso 
> <simone.dalmaso at juvox.it>wrote:
>
>> Hi,
>> I have a big problem.
>> I have a ejournal in my website and I have about 1000 articles.
>> Unfortunately, some of these are token from a website that has changed 
>> its
>> policy and don't allow us to publish its material: only the 25% of 
>> articles
>> can be published.
>> We can distinguish these articles because there is always the original 
>> link
>> that obviously starts with the same strings.
>> We must select all the articles containing these strings in their body, 
>> and
>> tells drupal to take the first 4 5 lines and delete the rest of contents.
>> I have 2 ideas, but I' not able to make it:
>> 1. with a sql query, I think all contents are in the node_revisions 
>> table.
>> 2. publishing only the teaser of the article.
>> I think the second method is easier, but have you got some ideas how
>> publish
>> only a teaser and hide the entire body of some nodes?
>>
>> thanks for your attention and patience.
>> Bye.
>>
>> --
>> [ Drupal support list | http://lists.drupal.org/ ]
>>
>


--------------------------------------------------------------------------------


> -- 
> [ Drupal support list | http://lists.drupal.org/ ] 



More information about the support mailing list