<?php require dirname(__FILE__) . '/../../model/President.php'; $Model = new President(); $insertData = array('facebook_id' => '1203983052', 'pic' => 'http://profile.ak.fbcdn.net/hprofile-ak-snc4/187226_1203983052_6480414_s.jpg', 'name' => 'Tatsuya Izumori'); echo $Model->insert($insertData) . "\n<br />"; var_dump($insertData);
// President,Princess,Party モデルを用意 $President = new President(); $Princess = new Princess(); $Party = new Party(); $Follower = new Follower(); // PresidentがDBに存在するか確認 $result = $President->findBy(array('facebook_id' => $facebook->getUser())); // ログイン中のPresiden情報 $me = array(); // MySQLにデータが存在しない場合はINSERT if ($result->num_rows == 0) { $fql = 'SELECT uid,name,pic_small,sex FROM user where uid = me()'; $r = $facebook->api(array('method' => 'fql.query', 'query' => $fql)); // Presidentデータを用意 $data = array('facebook_id' => $r[0]['uid'], 'name' => $r[0]['name'], 'pic' => $r[0]['pic_small'], 'updated_at' => time(), 'point' => 0, 'level' => 0, 'sex' => $r[0]['sex'] == 'male' ? 0 : 1); $President->insert($data); $me = $data; } else { $me = $result->fetch_assoc(); } $me['power'] = 0; $me['money'] = 0; // Party情報取得を試みる $party = array(); $partyResult = $Party->findBy(array('president_id' => $facebook->getUser())); // Partyが0以上 = 誰かしらデッキに入ってる場合 if ($partyResult->num_rows > 0) { while ($p = $partyResult->fetch_assoc()) { $follower = $Follower->findBy(array('facebook_id' => $p['follower_id'])); $f = $follower->fetch_assoc(); if (!is_null($f)) {