Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.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/2/ruby-on-rails/60.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 Wordpress表关联_Php_Mysql_Wordpress_Codeigniter - Fatal编程技术网

Php Wordpress表关联

Php Wordpress表关联,php,mysql,wordpress,codeigniter,Php,Mysql,Wordpress,Codeigniter,我有一个部分完成的插件可湿性粉剂,集成容易!将约会计划实用程序导入WP数据库。我需要联想简单!与WP用户预约用户 结构: 简单!约会数据库是mysql中WP数据库结构的一部分。容易的!约会是在Codeigniter框架中构建的。容易的!约会在WP内的iframe中运行 轻松!约会,用户表是ea_users,我知道我需要在ea user表中为wp_id创建另一列。因此,我将创建该列 ALTER TABLE `ea_users` ADD `wp_id` BIGINT(20) NOT NULL ;

我有一个部分完成的插件可湿性粉剂,集成容易!将约会计划实用程序导入WP数据库。我需要联想简单!与WP用户预约用户

结构:

简单!约会数据库是mysql中WP数据库结构的一部分。容易的!约会是在Codeigniter框架中构建的。容易的!约会在WP内的iframe中运行

轻松!约会,用户表是ea_users,我知道我需要在ea user表中为wp_id创建另一列。因此,我将创建该列

ALTER TABLE `ea_users` ADD `wp_id` BIGINT(20) NOT NULL ;
wp\u users
表中,我需要
id
user\u email
字段分别与
ea\u users
表中的
wp\u id
email
字段关联

这可以在mysql中通过某种关联实现吗?(那太好了)

或者我需要一些php代码(在sudo代码中):

如果我必须做PHP,那么我想那就可以了。如果我的逻辑不正确,请告诉我。此外,我还必须记住如何做到这一点,以便任何快速的提示都会得到赞赏,但不是预期的

问题:

  • 我可以简单地用某种关联链接mysql中的两个表吗

  • 伪代码中的逻辑看起来正确吗?是否有一个步骤我可能会错过

  • 关于如何在PHP中实现这一点,您有什么建议吗。例如,WP中是否有一些内置函数来完成此任务


  • 问题1的答案是否定的。
    问题2的答案是我认为我的逻辑是正确的。
    问题3的答案是肯定的,有一些内置的WP函数,我需要的是WP_get_current_user()和get_current_user_id()


    所以,这个问题的大部分都得到了回答。现在,我对codeigniter集成有一些疑问。

    到目前为止我所做的尝试:在我的控制器中——添加require_一次(“/path to wp/wp includes/user.php”);$wp_id=get_current_user_id();上述操作不起作用,因为我在codeigniter中调用它,所以它显示我没有登录。但是,在插件代码中添加以下内容:
    if(!function_exists('wp_get_current_user')){include(ABSPATH.wp includes/pluggable.php”)}$wp_id=get_current_user_id()
    返回已登录的用户,但不会将其传递给codeigniter。所以,我想我误解了钩子是如何工作的。
    On creating an E!A booking, check if the `wp_id` column for the user is null
    
     if is null: Get the the `wp_users` table, `user_email`  and current `id` and fill the `ea_users` table `wp_id` and `email`.
    
     else: check for matching `wp_users` `id` and `ea_users`  `wp_id`   
    
          if yes: match `ea_users`  `wp_id`   user with `wp_users` `id` and fill existing EA user data in to EA fields
    
          if no: delete the `ea_users`  `wp_id`   and get the `wp_users` table, `user_email`  and fill the `ea_users`  table `wp_id` and `email`.