Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 自定义wp post功能_Php_Sql_Wordpress - Fatal编程技术网

Php 自定义wp post功能

Php 自定义wp post功能,php,sql,wordpress,Php,Sql,Wordpress,我不打算实现所有的wp_post特性 我感兴趣的事情(这一直给我带来问题,因为我没有正确处理关系)是将值插入并更新到中的sql 1.员额表 2.术语表 3.术语分类法 4长期关系 当一个职位是 $sql="update wp_posts set post_title='$name', post_name='$slug', post_content='$freeRTE_content', post_category='$category', post_status='$post_status',

我不打算实现所有的wp_post特性

我感兴趣的事情(这一直给我带来问题,因为我没有正确处理关系)是将值插入并更新到中的sql 1.员额表 2.术语表 3.术语分类法 4长期关系

当一个职位是

$sql="update wp_posts set post_title='$name', post_name='$slug', post_content='$freeRTE_content', post_category='$category', post_status='$post_status', comment_status='$comment_status', mode_application='$howtoapply', website_address='$website', company_email='$email', application_deadline='$last_date', advert_date='$advert_date', post_date='$date', featured='$featured', course='$course', location='$location', grade='$grade' where id='$id'";
            if(mysql_query($sql, $link))
            {
                $expq=explode(',' , $q);foreach($expq as $key=>$value){$expq[$key]=trim($value);}$newq=join(',',$expq);
                $sql="insert into wp_term_relationships (term_taxonomy_id) select term_taxonomy_id from wp_term_taxonomy tt, wp_terms t where name in ('$newq') and taxonomy='post_tag' and t.term_id=tt.term_id";
                if(mysql_query($sql, $link))
                {
                    $sql="update wp_term_taxonomy tt, wp_terms t set count=count+1 where  name in ('$newq') and taxonomy='post_tag' and t.term_id=tt.term_id";
                    $result=mysql_query($sql, $link) or die(mysql_error($link));
                }

            }

        }
我没有弄清楚这四个表之间的关系,请问我怎样才能解决这个问题


(请注意,我不是在wordpress环境中工作,而是利用wordpress结构)

您有:

in ('$newq')
根据您的代码,您可能会遇到以下情况:

in ('tag1,tag2,tag3')
而不是需要和期望的:

in ('tag1','tag2','tag3')
你有:

in ('$newq')
根据您的代码,您可能会遇到以下情况:

in ('tag1,tag2,tag3')
而不是需要和期望的:

in ('tag1','tag2','tag3')

我想这就是我的问题所在:

$sql="insert into wp_term_relationships (term_taxonomy_id) select term_taxonomy_id from wp_term_taxonomy tt, wp_terms t where name in ('$newq') and taxonomy='post_tag' and t.term_id=tt.term_id";
正确的做法是:

$sql="insert into wp_term_relationships (object_id, term_taxonomy_id) values ('my_post_id', 'the term taxonomy id')";

谢谢大家

我想这就是我的问题所在:

$sql="insert into wp_term_relationships (term_taxonomy_id) select term_taxonomy_id from wp_term_taxonomy tt, wp_terms t where name in ('$newq') and taxonomy='post_tag' and t.term_id=tt.term_id";
正确的做法是:

$sql="insert into wp_term_relationships (object_id, term_taxonomy_id) values ('my_post_id', 'the term taxonomy id')";

谢谢大家

“我不是在wordpress环境中工作,而是在利用wordpress结构”-祝你好运“我不是在wordpress环境中工作,而是利用wordpress结构”-祝你好运