<?php require_once dirname(__FILE__) . '/../facebook.php'; require_once dirname(__FILE__) . "/../model/President.php"; require_once dirname(__FILE__) . "/../model/Follower.php"; require_once dirname(__FILE__) . "/../model/Party.php"; require_once dirname(__FILE__) . "/../model/Princess.php"; require_once dirname(__FILE__) . '/../calc_used_money.php'; // 下準備なう $President = new President(); $Follower = new Follower(); $Party = new Party(); $Princess = new Princess(); // facebook_idの取得 $facebook_id = $facebook->getUser(); // President情報の取得 $presidents = $President->findBy(array('facebook_id' => $facebook_id)); if ($presidents->num_rows == 0) { echo 'president取得の失敗なう'; die; } $president = $presidents->fetch_assoc(); // Presidentに紐付くParty情報の取得 $party = array(); $result = $Party->findBy(array('president_id' => $facebook_id)); while ($row = $result->fetch_assoc()) { array_push($party, $row); } // Presidentに紐付くPartyに紐付くFollowers情報の取得 $followers = array(); foreach ($party as $party_member) {
<?php require dirname(__FILE__) . '/../../model/Princess.php'; $Model = new Princess(); $insertData = array(); echo $Model->remove($insertData) . "\n<br />"; var_dump($insertData);
<?php require dirname(__FILE__) . '/../../model/Princess.php'; $Model = new Princess(); if ($resultRef = $Model->findAll()) { $result = $resultRef->fetch_all(); var_dump($result); } else { echo "No Result"; } if ($resultRef = $Model->findBy(array('id' => '2'))) { $result = $resultRef->fetch_all(); var_dump($result); } else { echo "No Result"; }
<?php require dirname(__FILE__) . '/../../model/Princess.php'; $Model = new Princess(); if ($resultRef = $Model->findAll()) { while ($result = $resultRef->fetch_assoc()) { var_dump($result); echo '<br />----------------------------<br />'; } } else { echo "No Result"; }
<?php require_once dirname(__FILE__) . '/../facebook.php'; require_once dirname(__FILE__) . "/../model/Princess.php"; // princessの構成 $fql = 'SELECT uid,pic,name FROM user WHERE uid IN ( SELECT uid2 FROM friend WHERE uid1 = me() )'; //echo $fql . "<br />"; $princesses = $facebook->api(array('method' => 'fql.query', 'query' => $fql)); //echo '<br />!!!!!!!!!!!!!!!!@@@@@@@@@@@@@@@@======================<br />'; // 【DB】 // 既にDBに登録されている姫: // 情報(Scoreとか)を引っ張ってくる // DBに未登録の姫: // 登録する $Model = new Princess(); for ($i = 0; $i < count($princesses); ++$i) { $resultRef = $Model->findBy(array('facebook_id' => $princesses[$i]['uid'])); if ($resultRef->num_rows != 0) { // 登録されてる姫 $result = $resultRef->fetch_assoc(); //var_dump($result); // 姫のDB値設定 $level = $result['level']; $score = $result['score']; $next_score = $result['next_score']; } else { // 登録されていない姫 // DBへInsert $data = array(); $data['facebook_id'] = $princesses[$i]['uid']; $data['name'] = $princesses[$i]['name'];
<?php /** * My Pageトップ画面 * 未ログインの場合はlogin.phpにリダイレクトされる * また、Partyが未選択の場合は自動的にFollower選択画面に遷移 */ require_once dirname(__FILE__) . '/../facebook.php'; require_once dirname(__FILE__) . '/../model/President.php'; require_once dirname(__FILE__) . '/../model/Princess.php'; require_once dirname(__FILE__) . '/../model/Party.php'; require_once dirname(__FILE__) . '/../model/Follower.php'; require_once dirname(__FILE__) . '/../calc_used_money.php'; // 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 {