myred08

第 369 位会员

会员
个人信息
  • 加入于 2018-03-07 11:20:25
  • 最后登录时间 2年前
个人成就
  • 发表文章次数 14
  • 发布回复次数 57
  • 个人主页浏览次数 19
产品添加Add to Favorites 失败。6年前

打印的结果就是string

object(fecshop\models\mysqldb\Customer)#76 (10) {
  ["_attributes":"yii\db\BaseActiveRecord":private]=>
  array(19) {
    ["id"]=>
    string(1) "2"
    ["password_hash"]=>
    string(60) "$2y$13$I4udjWohgTL8BFP7SfQAeurUu9lJ083xUDADwpQtUgmB9KNqnONVC"
    ["password_reset_token"]=>
    NULL
    ["email"]=>
    string(10) "aa@126.com"
    ["firstname"]=>
    string(4) "jiji"
    ["lastname"]=>
    string(2) "ji"
    ["is_subscribed"]=>
    int(1)
    ["auth_key"]=>
    string(32) "XZBZx6HCoYKj-nLssW7ZKIv_vTK4n4hD"
    ["status"]=>
    int(1)
    ["created_at"]=>
    int(1523432665)
    ["updated_at"]=>
    int(1523432665)
    ["password"]=>
    string(0) ""
    ["access_token"]=>
    string(32) "BQJkwszDllrGrjezyFKtjMe6trHKSxOm"
    ["birth_date"]=>
    NULL
    ["favorite_product_count"]=>
    int(4)
    ["type"]=>
    string(7) "default"
    ["access_token_created_at"]=>
    NULL
    ["allowance"]=>
    NULL
    ["allowance_updated_at"]=>
    NULL
  }
  ["_oldAttributes":"yii\db\BaseActiveRecord":private]=>
  array(19) {
    ["id"]=>
    string(1) "2"
    ["password_hash"]=>
    string(60) "$2y$13$I4udjWohgTL8BFP7SfQAeurUu9lJ083xUDADwpQtUgmB9KNqnONVC"
    ["password_reset_token"]=>
    NULL
    ["email"]=>
    string(10) "aa@126.com"
    ["firstname"]=>
    string(4) "jiji"
    ["lastname"]=>
    string(2) "ji"
    ["is_subscribed"]=>
    int(1)
    ["auth_key"]=>
    string(32) "XZBZx6HCoYKj-nLssW7ZKIv_vTK4n4hD"
    ["status"]=>
    int(1)
    ["created_at"]=>
    int(1523432665)
    ["updated_at"]=>
    int(1523432665)
    ["password"]=>
    string(0) ""
    ["access_token"]=>
    string(32) "BQJkwszDllrGrjezyFKtjMe6trHKSxOm"
    ["birth_date"]=>
    NULL
    ["favorite_product_count"]=>
    int(4)
    ["type"]=>
    string(7) "default"
    ["access_token_created_at"]=>
    NULL
    ["allowance"]=>
    NULL
    ["allowance_updated_at"]=>
    NULL
  }
  ["_related":"yii\db\BaseActiveRecord":private]=>
  array(0) {
  }
  ["_relationsDependencies":"yii\db\BaseActiveRecord":private]=>
  array(0) {
  }
  ["_errors":"yii\base\Model":private]=>
  NULL
  ["_validators":"yii\base\Model":private]=>
  NULL
  ["_scenario":"yii\base\Model":private]=>
  string(7) "default"
  ["_events":"yii\base\Component":private]=>
  array(0) {
  }
  ["_eventWildcards":"yii\base\Component":private]=>
  array(0) {
  }
  ["_behaviors":"yii\base\Component":private]=>
  array(0) {
  }
}
产品添加Add to Favorites 失败。6年前

好像是。 PHP取SQL数据库的问题。 PHP用pdo连接MYSQL会出现INT读取了变 string的情况。 请问fecshop的mysql连接方式是用pdo连接吗?

https://segmentfault.com/q/1010000002957162

产品添加Add to Favorites 失败。6年前

应该是写入session的时候出哪里问题了。为了完美还是找找哪里出问题了。

产品添加Add to Favorites 失败。6年前
    public function switchIdentity($identity, $duration = 0)
    {
        $this->setIdentity($identity);

        if (!$this->enableSession) {
            return;
        }

        /* Ensure any existing identity cookies are removed. */
        if ($this->enableAutoLogin && ($this->autoRenewCookie || $identity === null)) {
            $this->removeIdentityCookie();
        }

        $session = Yii::$app->getSession();
        if (!YII_ENV_TEST) {
            $session->regenerateID(true);
        }
        $session->remove($this->idParam);
        $session->remove($this->authTimeoutParam);

        if ($identity) {
			//var_dump($identity->getId());
			//exit();
            $session->set($this->idParam, $identity->getId());
			$session->set("testint", 2233);
			var_dump($session->get("testint"));
			exit();

添加测试代码

			$session->set("testint", 2233);
			var_dump($session->get("testint"));
			exit();

测试的结果是正常的。

产品添加Add to Favorites 失败。6年前

我安装的是 Redis-x64-3.2.100.msi 这个版本的redis. 另外 redis 好像 set 值都是 string类型的。没有整型的。redis 不熟悉。楼主有测试的PHP代码? 另外fecshop设置和读取redis的函数在哪里。

产品添加Add to Favorites 失败。6年前

session 的redis配置和你一样的。

    public function switchIdentity($identity, $duration = 0)
    {
        $this->setIdentity($identity);

        if (!$this->enableSession) {
            return;
        }

        /* Ensure any existing identity cookies are removed. */
        if ($this->enableAutoLogin && ($this->autoRenewCookie || $identity === null)) {
            $this->removeIdentityCookie();
        }

        $session = Yii::$app->getSession();
        if (!YII_ENV_TEST) {
            $session->regenerateID(true);
        }
        $session->remove($this->idParam);
        $session->remove($this->authTimeoutParam);

        if ($identity) {
			var_dump($identity->getId());
			exit();

执行退出重登录后,输出的还是 string(1) "2" 同时发现redis里面的内容好像类型就是 string的。

再次执行清空redis seesion所有数据。重新登录后 查看redis记录是

__flash|a:0:{}currency_current|s:3:"USD";FBRLH_state|s:32:"f9fd12780aa786c202a50eb88b997c52";__id|s:1:"2";current_session_cart_id|s:1:"7";

按理说应该是 __id|i:2; 吧? 我redis不熟悉 :(

产品添加Add to Favorites 失败。6年前
    protected function renewAuthStatus()
    {
        $session = Yii::$app->getSession();
        $id = $session->getHasSessionId() || $session->getIsActive() ? $session->get($this->idParam) : null;
		var_dump($id);
		var_dump($session->getHasSessionId());
		var_dump($session->getIsActive());
		var_dump($session->get($this->idParam));

输入的结果为

string(1) "2"
bool(true)
bool(true)
string(1) "2"

应该是这个有问题 $session->get($this->idParam) 这个在哪个文件里面?

产品添加Add to Favorites 失败。6年前

\vendor\fancyecommerce\fecshop\services\product\Favorite.php

    protected function actionList($filter)
    {
		echo("改前:");
		var_dump($filter);

你可以输出看一下变量

另外这个/app/appfront/modules/Customer/block/productfavorite/Index.php文件,user_id是string类型的。

    public function getLastData()
    {
        $this->initFavoriteParam();
        $identity = Yii::$app->user->identity;
        $user_id = $identity->id;
		var_dump($user_id);

mysql表格结构没有错误是int类型的,另外我也是刚研究。没有改东西呢。

产品添加Add to Favorites 失败。6年前

#8楼 和mysql表没关系。 favorite表是在mongodb里面。 你用什么软件查看 mongodb表结构? 我现在是用一个插件看不到结构。 另外我是根据 http://www.fecshop.com/topic/527 安装的系统。

产品添加Add to Favorites 失败。6年前

恩。linux可能没有关系吧。 windows是有BUG。

产品添加Add to Favorites 失败。6年前

/app/appfront/modules/Customer/block/productfavorite/Index.php

第34行改为
        $user_id = (int)$identity->id;

把user_id类型强制转成int发现。就可以显示了。 不知道是不是我mongodb没有升级数据库的原因? 另外是windows 环境下的BUG。

产品添加Add to Favorites 失败。6年前

用的是最新版的。1.4.1.0 查看mongodb数据中是,添加成功了。有记录。但是无法显示。 不知道id=0是什么意思。 我的会员ID是2

PHPStudy下安装Fecshop全过程6年前

@19楼 在第10步就遇到大坑了。

10.重启phpstudy服务,然后cmd命令行: cd /d D:\phpStudy\WWW\fecshop

init

一直提示 The OpenSSL PHP extension is required by Yii2. 但是明明安装好了openssl扩展。 一步步排查发现是自己的环境变量Path设置的值出问题了。 因为之前是用 php5.4 ,又改成 5.6的。之前的没有删除。

最后自己用完整的命令。运行一次就没出错了。

"C:\phpStudy\php\php-5.6.27-nts\php.exe" "C:\phpStudy\www\fecshop\init"

"C:\phpStudy\php\php-5.6.27-nts\php.exe" "C:\phpStudy\www\fecshop\yii" migrate --interactive=0 --migrationPath=@fecshop/migrations/mysqldb

"C:\phpStudy\php\php-5.6.27-nts\php.exe" "C:\phpStudy\www\fecshop\yii" mongodb-migrate --interactive=0 --migrationPath=@fecshop/migrations/mongodb

直接用(init , yii)发现有几个坑。如果被坑用我这个方法试试。
uses an image, skipping6年前

非常感谢。。:smiley: :smiley:

Your Site Analytics