向MySQL添加数据列表

时间:2015-05-04 05:54:32

标签: php mysql

我有一些数据要添加到我的数据库中,我不确定我的表架构应该是什么。我有每个特定用户的ID号,4类游戏,以及每个用户为每个游戏拥有的可能数量的项目(0+)。我想为每个游戏设置一个表格,其中包含类别 - > id和 - >项目,因此我可以将表格中的用户ID列表保存到该游戏中。

我觉得我无法让它工作,我认为是因为每个用户的动态项目数。我可以实现上面提到的表模式吗?为什么不/如何?

我一直在努力:

foreach ($json->rgDescriptions as $mydata)
        {    
         $sql = $dbh->prepare('INSERT INTO user_items_tf2 (items) VALUES (:item) WHERE steam_id = :steamid');
         $sql->bindParam(':item', $mydata->name);
         $sql->bindParam(':steamid', $steamprofile['steamid']);
         $sql->execute();
    }

1 个答案:

答案 0 :(得分:1)

有很多方法可以做到这一点,但有一个非常灵活,似乎可以回答你的问题。

player

如果您从不需要询问用户具有给定项目的问题,您可以跳过player_item表并将其项目的数据(例如JSON)填充到带有blob的import Foundation import WatchKit import CoreLocation class NearByController: WKInterfaceController, CLLocationManagerDelegate { var locationManager = CLLocationManager() override func awakeWithContext(context: AnyObject?) { locationManager.delegate = self locationManager.desiredAccuracy = kCLLocationAccuracyBest locationManager.requestWhenInUseAuthorization() if CLLocationManager.locationServicesEnabled() { locationManager.startUpdatingLocation() } } // MARK: CLLocationManagerDelegate func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { locationManager.stopUpdatingLocation() println(locations) } func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!) { println(error) } 表的列中类型。