使用Magento API v/s纯MySQL [英] Using Magento API v/s plain MySQL

查看:110
本文介绍了使用Magento API v/s纯MySQL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的任务是将phpbb论坛连接到现有的Magento数据库.

I've been tasked with connecting a phpbb forum to an existing Magento database.

此方法的工作方式是:

  1. 新用户在基于magento的网站上注册,并选择论坛用户名和网站用户名(可以相同).这样,他们就可以在两个地方使用相同的凭据.
  2. 某些注册逻辑需要根据用户信息填充其他数据库字段.
  3. 在对现有phpbb用户进行身份验证时,将使用Magento的数据库.

我使用Magento的API在1中填充表格,并在3中使用普通的MySQL查询/更新.尽管如此,我仍然停留在2.

I used Magento's API for populating the table in 1, and plain MySQL queries/updates in 3. I'm stuck at 2 though.

对于2,由phpbb访问的字段将仅由phpbb论坛(除了论坛用户名)更新,而不会由Magento网站更新.对我而言,使用Magento的API似乎是一个非常乏味的选择,对于我的情况而言,这是不必要的.

For 2, the fields accessed by phpbb will be updated only by the phpbb forum (well, apart from the forum username), and never by the Magento site. Using Magento's API seems like an awfully tedious option and to my naive mind, unnecessary for my situation.

那么,我应该使用Magento API还是普通的MySQL插入,为什么?

So, should I use the Magento API or plain MySQL inserts, and why?

推荐答案

选择Magento API.您不仅不必模拟生成整个哈希(它们使用2字符的盐并将其附加到MD5哈希中),而且还不必担心何时/如果他们决定更新数据库架构或哈希机制.

Pick the Magento API. Not only do you not have to emulate generating the whole hash (they use a 2 character salt and append it to an MD5 hash), you also won't have to worry when/if they decide to update the database schema or hashing mechanism.

更改用户密码非常简单;

Changing a user password is pretty simple;

require_once 'app/Mage.php';

Mage::init('admin');

$customer = Mage::getModel('customer/customer')->load(123); // whatever the user ID is
$customer->changePassword('whatever_new_password');

这篇关于使用Magento API v/s纯MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆