[wp-hackers] $wpdb query
Cori Schlegel
kinrowan at gmail.com
Wed Sep 20 03:24:54 GMT 2006
In my (upgraded from 1.5 -> 2...) posts table, the key field is ID, not
post_ID. When I run
"UPDATE xx_posts SET post_parent = 1 WHERE ID = 2 AND post_status =
'static'"
in phpMySQL I get a returned row. Haven't tried it in PHP.
Corresponding T-SQL for categories is
"UPDATE xx_categories SET category_parent = 1 WHERE cat_ID = 2"
I believe.
ryan fitzer wrote:
> Thanks for the help. It is the SQL that I'm having trouble with but your
> explanation helped in other ways. Here is what I've used for a subpage
> without success:
>
> $wpdb->query("UPDATE $wpdb->posts SET post_parent = 3 WHERE post_ID =
> 4 AND post_status = 'static'");
>
> Got no results from this. And no clue what the query would look like
> with a
> sub-cat.
>
> Ryan
>
> On 9/19/06, Robin Adrianse <shorty114 at shorty114.net> wrote:
>>
>> Like you said, I'm not sure if this is the best place for a request like
>> this, but here's my answer:
>>
>> Categories: A category is made a subcategory by setting
>> category_parent to
>> something other than 0, namely the ID of the category which is its
>> parent.
>> If it is 0, then it will just be handled as a root category (no
>> parents).
>> If
>> you can't figure out the SQL for this, feel free to ask.
>>
>> Pages: First off, a page is differentiated from a post by the setting of
>> post_status. Pages always have it set to "static" (without quotes, of
>> course), and posts can have it published, draft and private. That
>> said, a
>> page is made a sub-page similarly to a category. There is a field
>> post_parent which is the ID of the page's parent. If it is 0, it is a
>> root-level page.
>>
>> I hope this answered your questions.
>>
>> On 9/19/06, ryan fitzer <ryanfitzer at gmail.com> wrote:
>> >
>> > Tried the forums but I'm not sure if that's the place for it.
>> >
>> > Anyone know the query to add a sub-category and a sub-page in
>> install.php?
>> > I
>> > want to be able to use it to do auto set-ups for custom themes. Any
>> help
>> > would be great.
>> >
>> > I'm also trying this for WordPress MU for a different project.
>> > I've successfully added an extra category, post and page. I'm so
>> close!
>> > Thanks for any help.
>> > --
>> > Ryan Fitzer
>> > _______________________________________________
>> > wp-hackers mailing list
>> > wp-hackers at lists.automattic.com
>> > http://lists.automattic.com/mailman/listinfo/wp-hackers
>> >
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>
>
>
More information about the wp-hackers
mailing list