- Timestamp:
- 10/01/08 07:41:06 (3 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
events/phpframework/plain_php/trunk/model/phwittr/AcountService.php
r20036 r20338 3 3 class AcountService 4 4 { 5 /** 6 * @var PDO 7 */ 5 8 protected $pdo; 6 9 … … 36 39 $smt->bindValue(':delete_flag', $delete_flag, PDO::PARAM_INT); 37 40 $smt->execute(); 38 return $smt->rowCount() === 1 ? true : false;41 return $smt->rowCount() === 1; 39 42 } 40 43 function updatePicture($user_id, $image) … … 50 53 } 51 54 $smt->execute(); 52 return $smt->rowCount() === 1 ? true : false;55 return $smt->rowCount() === 1; 53 56 } 54 57 function updatePassword($user_id, $password) … … 61 64 $smt->bindValue(':password', $password, PDO::PARAM_STR); 62 65 $smt->execute(); 63 return $smt->rowCount() === 1 ? true : false;66 return $smt->rowCount() === 1; 64 67 } 65 68 function updateEmail($user_id, $email) … … 70 73 $smt->bindValue(':email', $email, PDO::PARAM_STR); 71 74 $smt->execute(); 72 return $smt->rowCount() === 1 ? true : false;75 return $smt->rowCount() === 1; 73 76 } 74 77 … … 94 97 $smt->bindValue(':act_key', $act_key, PDO::PARAM_STR); 95 98 $smt->execute(); 96 return $smt->rowCount() === 1 ? true : false;99 return $smt->rowCount() === 1; 97 100 } 98 101 99 102 function setPrivate($user_id) 100 103 { 101 // @todo 後で実装する 102 return true; 104 $smt = $this->pdo->prepare(' 105 update users set private_flag = 1 where id = :user_id limit 1 106 '); 107 $smt->bindValue(':user_id', $user_id, PDO::PARAM_INT); 108 $smt->execute(); 109 return $smt->rowCount() === 1; 103 110 } 104 111 function setPublic($user_id) 105 112 { 106 // @todo 後で実装する 113 $this->pdo->beginTransaction(); 114 115 $smt = $this->pdo->prepare(' 116 update users set private_flag = 0 where id = :user_id limit 1 117 '); 118 $smt->bindValue(':user_id', $user_id, PDO::PARAM_INT); 119 $smt->execute(); 120 121 if (!$smt->rowCount() === 1) { 122 $this->pdo->rollBack(); 123 return false; 124 } 125 126 $smt = $this->pdo->prepare(' 127 select * from requests 128 where request_id = :user_id 129 '); 130 $smt->bindValue(':user_id', $user_id, PDO::PARAM_INT); 131 $smt->execute(); 132 $arr = $smt->fetchAll(PDO::FETCH_ASSOC); // $user_idをリクエストしている行列を得る 133 if ($arr == false) { 134 $this->pdo->commit(); 135 return true; 136 } 137 138 foreach ($arr as $r) { 139 $smt = $this->pdo->prepare(' 140 insert into 141 followers(user_id, follow_id, created_at) 142 values(:user_id, :follow_id, NOW()) 143 '); 144 $smt->bindValue(':user_id', $r['user_id'], PDO::PARAM_INT); 145 $smt->bindValue(':follow_id', $user_id, PDO::PARAM_INT); 146 $smt->execute(); 147 } 148 149 $smt = $this->pdo->prepare(' 150 delete from requests where request_id = :user_id 151 '); 152 $smt->bindValue(':user_id', $user_id, PDO::PARAM_INT); 153 $smt->execute(); 154 155 $this->pdo->commit(); 107 156 return true; 108 157 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)