コード例 #1
0
ファイル: index.php プロジェクト: shenshawvfs/AngualarApp
 public function handleAction($request)
 {
     // The 'action' requested is named for the folder this server lives in
     $username = $request['nickname'];
     $response['id'] = 0;
     // User zero by default, will be updated.
     $response['nickname'] = "unknown";
     $response['error'] = 1;
     $userTable = new UsersTable();
     // First try and see if this user exists (by nickname)
     $result = $userTable->readByNickname($username);
     if (empty($result)) {
         // If they don't exist, create them.
         $data = array('id' => $response['id'], 'nickname' => $username);
         if ($userTable->create($data)) {
             $response['nickname'] = $username;
             $response['error'] = 0;
         }
     } else {
         $response['id'] = $result[0]->id;
         $response['nickname'] = $result[0]->nickname;
         $response['error'] = 0;
     }
     return $response;
 }
コード例 #2
0
ファイル: TableTest.php プロジェクト: quenti77/phq
 /**
  * Test la définition du nom de la table
  */
 public function testSetEntityName()
 {
     $connection = new Connection('mysql:host=localhost;dbname=phq', 'phq', 'phq');
     $catched = false;
     try {
         $table = new Table($connection);
     } catch (InvalidArgumentException $e) {
         $this->assertEquals('The name of table is impossible', $e->getMessage());
         $catched = true;
     }
     $this->assertTrue($catched);
     $usersTable = new UsersTable($connection);
     $this->assertEquals('User', $usersTable->entityName);
     $userMessagesTable = new UserMessagesTable($connection);
     $this->assertEquals('UserMessage', $userMessagesTable->entityName);
     $usersTable = new UsersTable($connection, 'newbies');
     $this->assertEquals('Newby', $usersTable->entityName);
     $usersTable->setEntityName('Beaches');
     $this->assertEquals('Beach', $usersTable->entityName);
     $usersTable->setEntityName('News');
     $this->assertEquals('News', $usersTable->entityName);
 }
コード例 #3
0
ファイル: UserService.php プロジェクト: tests1/zendcasts
 public function GetUsersByContactType(Zend_Db_Table_Row $row)
 {
     return $this->users->fetchAll($this->users->select()->where('contacttype_id = ?', $row->id));
 }
コード例 #4
0
 /**
  * Tests the alias method
  *
  * @return void
  */
 public function testAliasMethod()
 {
     $table = new Table(['alias' => 'users']);
     $this->assertEquals('users', $table->alias());
     $table = new Table(['table' => 'stuffs']);
     $this->assertEquals('stuffs', $table->alias());
     $table = new UsersTable();
     $this->assertEquals('Users', $table->alias());
     $table = $this->getMockBuilder('\\Cake\\ORM\\Table')->setMethods(['find'])->setMockClassName('SpecialThingTable')->getMock();
     $this->assertEquals('SpecialThing', $table->alias());
     $table->alias('AnotherOne');
     $this->assertEquals('AnotherOne', $table->alias());
 }
コード例 #5
0
 //$email = filter_var($formdata['username'], FILTER_VALIDATE_EMAIL);
 //if ($email != $formdata['username']) {
 //    $errors['username'] = "******";
 //}
 if (empty($formdata['password'])) {
     $errors['password'] = "******";
 }
 if (empty($errors)) {
     // since none of the form fields were empty,
     // store the form data in variables
     $username = $formdata['username'];
     $password = $formdata['password'];
     // create a UserTable object and use it to retrieve
     // the users
     $connection = Connection::getInstance();
     $userTable = new UsersTable($connection);
     $user = $userTable->getUserByUsername($username);
     // since password fields match, see if the username
     // has already been registered - if it is then throw
     // and exception
     if ($user == null) {
         $errors['username'] = "******";
     } else {
         if ($password !== $user->getPassword()) {
             $errors['password'] = "******";
         }
     }
 }
 if (!empty($errors)) {
     throw new Exception("There were errors. Please fix them.");
 }
コード例 #6
0
ファイル: chat.php プロジェクト: kveler/webchat
 public function userToDatabase()
 {
     $users = new UsersTable();
     $users->insert(array("voornaam" => $_POST['user'], "email" => $_POST['email']));
     Session::set("user", $_POST['user']);
 }
コード例 #7
0
ファイル: UserService.php プロジェクト: tests1/zendcasts
 public function GetAllUsers()
 {
     $select = $this->users->select();
     $select->order('name');
     return $this->users->fetchAll($select);
 }