[PHP][DEV] Base user class

Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 31
  1. #16
    hoi ik ben cool Merijn is offline
    MemberRank
    Dec 2009 Join Date
    The NetherlandsLocation
    492Posts

    Re: [PHP][DEV] Base user class

    Quote Originally Posted by Quackster View Post
    If it's a release, let me see you use it then!

    EDIT: Yes it is a development [DEV] at the top!
    Oh noez, get out; It's an l33t person with skillz y'know br0

  2. #17
    Account Upgraded | Title Enabled! Pure is offline
    MemberRank
    May 2008 Join Date
    809Posts

    Re: [PHP][DEV] Base user class

    Quote Originally Posted by Quackster View Post
    If it's a release, let me see you use it then!

    EDIT: Yes it is a development [DEV] at the top!
    It's a release; yes! However, the [dev] tap is because it's not finished! I want people to use this in their software.

  3. #18
    Alpha Member Zak© is offline
    MemberRank
    Oct 2007 Join Date
    2,693Posts

    Re: [PHP][DEV] Base user class

    Oddly. I understand all of this code.

    This is just c# to me so i guess i could help mwhaha. But let me learn some basics of PHP.

    I know the variables are auto assigned just reminds me of the var function in C#.

    Any how this looks good seems you have your own Query classes which is pretty neat to.

    I wonder if there interfaces in PHP hmm.. time for google.

    Any how good luck! With your development. I'm sure it will be even better and good as just as this User class.

    Edit

    interface
    iTemplate
    {
    public function
    setVariable($name, $var);
    public function
    getHtml($template);
    }

    I'm so going PHP...



    Code:
    <!-- Compose Mysql Query -->
    interface IMySqlComposer
    {
        <!-- Paramters is a Object array -->
        public function executeQuery($Parameters;
        <!-- Type is a Type, Parameters is a Object array -->
        public function getResultl($Type, $Parameters);
    }
    Ported a Interface from C# :O

  4. #19
    The one and only! Hejula is offline
    MemberRank
    Nov 2008 Join Date
    4,128Posts

    Re: [PHP][DEV] Base user class

    Quote Originally Posted by Zak© View Post
    Oddly. I understand all of this code.

    This is just c# to me so i guess i could help mwhaha. But let me learn some basics of PHP.

    I know the variables are auto assigned just reminds me of the var function in C#.

    Any how this looks good seems you have your own Query classes which is pretty neat to.

    I wonder if there interfaces in PHP hmm.. time for google.

    Any how good luck! With your development. I'm sure it will be even better and good as just as this User class.

    Edit

    interface
    iTemplate
    {
    public function
    setVariable($name, $var);
    public function
    getHtml($template);
    }

    I'm so going PHP...



    Code:
    <!-- Compose Mysql Query -->
    interface IMySqlComposer
    {
        <!-- Paramters is a Object array -->
        public function executeQuery($Parameters;
        <!-- Type is a Type, Parameters is a Object array -->
        public function getResultl($Type, $Parameters);
    }
    Ported a Interface from C# :O
    Lol :P

    You just copied from the manual - PHP: Object Interfaces - Manual

  5. #20
    Gamma Spamma Liam is offline
    MemberRank
    Dec 2011 Join Date
    Down UnderLocation
    2,946Posts

    Re: [PHP][DEV] Base user class

    This is like UberCMS, they use guest and user classes

  6. #21
    ex visor Aaron is offline
    MemberRank
    May 2007 Join Date
    MichiganLocation
    4,028Posts
    It would make sense to do it that way, so you can easily differentiate which content you'd like to display, depending on the request being made.


    Sent from my iPhone 4S using Tapatalk

  7. #22
    Alpha Member Zak© is offline
    MemberRank
    Oct 2007 Join Date
    2,693Posts

    Re: [PHP][DEV] Base user class

    Quote Originally Posted by Hejula View Post
    Lol :P

    You just copied from the manual - PHP: Object Interfaces - Manual
    I googled for PHP interface's quickly read that manual.
    Pasted that code.
    Then i just made my own.

    This was done within 2 minutes.

    Am i badass or what.

  8. #23
    Ultra Light Beam Makarov is offline
    MemberRank
    Apr 2010 Join Date
    GothamLocation
    3,622Posts

    Re: [PHP][DEV] Base user class

    This looks pretty different from what a lot of people are doing. I do like the way you search if the session keys are set. You could just return false instead of using the variable y in my opinion(from what I skimmed). Nice though.

  9. #24
    Banned Sniffy is offline
    BannedRank
    Jan 2012 Join Date
    CanadaLocation
    42Posts

    Re: [PHP][DEV] Base user class

    Nice release but I have some suggestions. I do not understand why you are doing some of the following... like it is really redundant.

    Code:
    public function Users( Core $core )
            {
                
                $this->iCore = $core;
                
                $this->searchForSessions();
                
            }
    
    ...
    That is your constructor, setting the instance variable $iCore to the parameter variable $core. Now in some of your methods you do this:

    Code:
    protected function searchForSessions()
            {
                
                global $core;
    
    ...
    But you never actually use $core, you use $this->iCore. Just thought you might want to fix that up. You also might want to change the following:

    Code:
    ...
    
    SELECT 
    
                                            u.*, b.expire, b.reason
    
                                        FROM 
    
                                            users AS u 
                                            
                                        LEFT JOIN 
                                        
                                            bans AS b 
                                         
                                        ON 
                                        
                                            ( u.username = b.value OR b.value = ? ) AND ( UNIX_TIMESTAMP() - b.expire < 0 )
    
                                        WHERE
    
                                            u.username = ?
    
                                        AND 
    
                                            u.password = ?
                                            
                                        LIMIT 1;
    
    ...
    Change the 'LEFT JOIN' to 'INNER JOIN' or 'JOIN' (alias).

  10. #25
    Live Ocottish Sverlord Joopie is offline
    LegendRank
    Jun 2010 Join Date
    The NetherlandsLocation
    2,773Posts

    Re: [PHP][DEV] Base user class

    Quote Originally Posted by Sniffy View Post
    Nice release but I have some suggestions. I do not understand why you are doing some of the following... like it is really redundant.

    Code:
    public function Users( Core $core )
            {
                
                $this->iCore = $core;
                
                $this->searchForSessions();
                
            }
    
    ...
    That is your constructor, setting the instance variable $iCore to the parameter variable $core. Now in some of your methods you do this:

    Code:
    protected function searchForSessions()
            {
                
                global $core;
    
    ...
    But you never actually use $core, you use $this->iCore. Just thought you might want to fix that up.
    Thank you for repeating me, already sayed...

    You also might want to change the following:

    Code:
    ...
    
    SELECT 
    
                                            u.*, b.expire, b.reason
    
                                        FROM 
    
                                            users AS u 
                                            
                                        LEFT JOIN 
                                        
                                            bans AS b 
                                         
                                        ON 
                                        
                                            ( u.username = b.value OR b.value = ? ) AND ( UNIX_TIMESTAMP() - b.expire < 0 )
    
                                        WHERE
    
                                            u.username = ?
    
                                        AND 
    
                                            u.password = ?
                                            
                                        LIMIT 1;
    
    ...
    Change the 'LEFT JOIN' to 'INNER JOIN' or 'JOIN' (alias).
    Go learn the SQL syntax and then come back...


  11. #26
    Banned Sniffy is offline
    BannedRank
    Jan 2012 Join Date
    CanadaLocation
    42Posts

    Re: [PHP][DEV] Base user class

    Quote Originally Posted by joopie View Post
    Thank you for repeating me, already sayed...



    Go learn the SQL syntax and then come back...

    Joopie your error is a common error that occurs when you do not set the expire column in the database. Take a look and then fix your local settings.

    Exhibit 1:



    Exhibit 2: (suggested query)

    Code:
    SELECT u.*, b.expire, b.reason
    FROM users u 
    INNER JOIN bans b
    ON u.username = b.value
    WHERE u.username = ?
    	AND u.password = ?
    	AND (UNIX_TIMESTAMP() - b.expire) < 0
    ORDER BY b.id DESC
    LIMIT 1;
    Exhibit 3:

    Last edited by Sniffy; 26-01-12 at 08:38 PM. Reason: Adding order rule to query.

  12. #27
    Live Ocottish Sverlord Joopie is offline
    LegendRank
    Jun 2010 Join Date
    The NetherlandsLocation
    2,773Posts

    Re: [PHP][DEV] Base user class

    Quote Originally Posted by Sniffy View Post
    Joopie your error is a common error that occurs when you do not set the expire column in the database. Take a look and then fix your local settings.

    Exhibit 1:



    Exhibit 2: (suggested query)

    Code:
    SELECT u.*, b.expire, b.reason
    FROM users u 
    INNER JOIN bans b
    ON u.username = b.value
    WHERE u.username = ?
    	AND u.password = ?
    	AND (UNIX_TIMESTAMP() - b.expire) < 0
    LIMIT 1;
    Exhibit 3:

    Lolz, `common error` There is NO ERROR.

    There is nothing wrong with LEFT JOIN.

    And there should nothing to-be fix /facepalm
    ...

    Go remove yourself form the banlist.
    You should see that it doens't work anymore

    LEFT JOIN isn't equal to INNER JOIN.

    When you have 2 tables
    The first table has a row with id 1
    And the second row is empty
    When you use INNER JOIN like `table1`.`id` = `table2`.`id` you don't get any results.
    But if you do LEFT JOIN you still get the row that's in table 1 even if he can't select the row from table 2.

    BIG diffrents..
    And may be used both as it is a default MySQL function...

    *Why making it harder when it can be easily done*

  13. #28
    Banned Sniffy is offline
    BannedRank
    Jan 2012 Join Date
    CanadaLocation
    42Posts

    Re: [PHP][DEV] Base user class

    Quote Originally Posted by joopie View Post
    Lolz, `common error` There is NO ERROR.

    There is nothing wrong with LEFT JOIN.

    And there should nothing to-be fix /facepalm
    ...

    Go remove yourself form the banlist.
    You should see that it doens't work anymore

    LEFT JOIN isn't equal to INNER JOIN.

    When you have 2 tables
    The first table has a row with id 1
    And the second row is empty
    When you use INNER JOIN like `table1`.`id` = `table2`.`id` you don't get any results.
    But if you do LEFT JOIN you still get the row that's in table 1 even if he can't select the row from table 2.

    BIG diffrents..
    And may be used both as it is a default MySQL function...

    *Why making it harder when it can be easily done*
    Joopie I am well aware that LEFT JOIN and INNER JOIN or JOIN (alias) are different. It would make no sense to a suggest a change if they meant the same thing. According to the logic and how the query should be structured, INNER JOIN or JOIN (alias) is the appropriate way to handle this.

    Go do some research on SQL rather than posting the same thing (your wrong opinion) over and over and over again. It would be a better use of your time.

  14. #29
    Live Ocottish Sverlord Joopie is offline
    LegendRank
    Jun 2010 Join Date
    The NetherlandsLocation
    2,773Posts

    Re: [PHP][DEV] Base user class

    Quote Originally Posted by Sniffy View Post
    Joopie I am well aware that LEFT JOIN and INNER JOIN or JOIN (alias) are different. It would make no sense to a suggest a change if they meant the same thing. According to the logic and how the query should be structured, INNER JOIN or JOIN (alias) is the appropriate way to handle this.

    Go do some research on SQL rather than posting the same thing (your wrong opinion) over and over and over again. It would be a better use of your time.
    If you want to add for every user that you have a row in your ban table, success with that *fail*

    Go do some research on SQL rather than posting the same thing (your wrong opinion) over and over and over again. It would be a better use of your time.

  15. #30
    Banned Sniffy is offline
    BannedRank
    Jan 2012 Join Date
    CanadaLocation
    42Posts

    Re: [PHP][DEV] Base user class

    Quote Originally Posted by joopie View Post
    If you want to add for every user that you have a row in your ban table, success with that *fail*

    Go do some research on SQL rather than posting the same thing (your wrong opinion) over and over and over again. It would be a better use of your time.
    Ok first I thought you were confused. Now I know you are just out right stupid. I am going to add comments to both queries to make it more like pseudocode. So pay attention.

    Original Query:

    Code:
    SELECT u.*, b.expire, b.reason # Selects all the columns from the 'users' table and two columns from the 'bans' table.
    FROM users AS u # Choosing the 'users' table to select the columns from. Setting alias 'u'.
    LEFT JOIN bans AS b # Loading all the results from the 'bans' table. Setting alias 'b'.
    ON ( u.username = b.value OR b.value = ? ) AND ( UNIX_TIMESTAMP() - b.expire < 0 ) # Matching only results from 'users' table that has a username of the 'bans' table value column. Ensuring unix timestamp is not expired (I do not know why he did that check in this part of the query...).
    WHERE u.username = ? # Where the username is the first parameter...
    	AND u.password = ? # ... and the password is the second parameter.
    LIMIT 1; # Only display the first returned row from the query.
    New Query: (suggested query pseudo)

    Code:
    SELECT u.*, b.expire, b.reason # Selects all the columns from the 'users' table and two columns from the 'bans' table.
    FROM users u # Choosing the 'users' table to select the columns from. Setting alias 'u'.
    INNER JOIN bans b # Loading conditional results (condition below). Setting alias 'b'.
    ON u.username = b.value # Only grabbing pair matches in both tables, condition is username.
    WHERE u.username = ? # Where the username is the first parameter...
    	AND u.password = ? # ... and the password is the second parameter...
    	AND (UNIX_TIMESTAMP() - b.expire) < 0 # ... and the unix timestamp minus expiration is less than 0 (expired).
    ORDER BY b.id DESC # Order ban results in descending order to get the most recent ban.
    LIMIT 0,1; # Only display the first returned row from the query.
    Last edited by Sniffy; 26-01-12 at 08:45 PM. Reason: Typo with a word, bothers me.



Page 2 of 3 FirstFirst 123 LastLast

Advertisement