mirror of
				https://github.com/pierre42100/ComunicAPI
				synced 2025-11-04 04:04:20 +00:00 
			
		
		
		
	Can get account ID from email
This commit is contained in:
		@@ -198,6 +198,30 @@ class AccountComponent {
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Get the ID of the account associated with an email address
 | 
			
		||||
	 * 
 | 
			
		||||
	 * @param string $email The email address
 | 
			
		||||
	 * @return int The ID of the account / -1 in case of failure
 | 
			
		||||
	 */
 | 
			
		||||
	public function getIDfromEmail(string $email): int {
 | 
			
		||||
 | 
			
		||||
		//Perform an API request
 | 
			
		||||
		$tableName = self::USER_TABLE;
 | 
			
		||||
		$conditions = "WHERE mail = ?";
 | 
			
		||||
		$values = array($email);
 | 
			
		||||
 | 
			
		||||
		//Peform the request
 | 
			
		||||
		$values = cs()->db->select($tableName, $conditions, $values);
 | 
			
		||||
 | 
			
		||||
		if(count($values) == 0)
 | 
			
		||||
			return -1; //No result found
 | 
			
		||||
		
 | 
			
		||||
		//Return first value
 | 
			
		||||
		return $values[0]["ID"];
 | 
			
		||||
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/**
 | 
			
		||||
	 * Intend to create an account
 | 
			
		||||
	 * 
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user