_getMarketMysql(), 't_nft', array( 'owner_address' => myself()->_getOpenId(), 'token_type' =>Nft::FRAGMENT_TYPE, 'deleted' => 0 ) ); foreach ($nft as $nftDb) { $row = SqlHelper::ormSelectOne( myself()->_getSelfMysql(), 't_fragment', array( 'token_id' => $nftDb['token_id'], ) ); // if (!$row) { // $itemMeta = mt\Item::get($nftDb['item_id']); // if ($itemMeta) { // self::addFragment($itemMeta, $nftDb['token_id']); // $row = SqlHelper::ormSelectOne( // myself()->_getSelfMysql(), // 't_fragment', // array( // 'token_id' => $nftDb['token_id'], // ) // ); // } // } if ($row) { $cb($row); } } } public static function addFragment($fragmentMeta, $tokenId) { return self::internalAddHero( myself()->_getMysql($tokenId), $fragmentMeta, null, $tokenId); } public static function internalAddHero($conn, $fragmentMeta, $accountId, $tokenId) { $fieldsKv = array( 'item_id' => $fragmentMeta['id'], 'type' => $fragmentMeta['sub_type'], 'parts' => substr($fragmentMeta['id'],-2,1), 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime() ); if ($accountId) { $fieldsKv['account_id'] = $accountId; } if ($tokenId) { $fieldsKv['token_id'] = $tokenId; } SqlHelper::insert( myself()->_getSelfMysql(), 't_fragment', $fieldsKv ); } public static function getFragmentByIdx($idx){ return SqlHelper::ormSelectOne( myself()->_getSelfMysql(), 't_fragment', array( 'idx' => $idx, ) ); } // public static function deleteFragment($whereKv){ // SqlHelper::update( // myself()->_getMarketMysql(), // 't_nft', // $whereKv, // ['deleted'=>1] // ); // } }