PHP Classes

File: examples/cms/app/models/usersModel.php

Recommend this page to a friend!
  Packages of Haseeb Ahmad Basil   PHP Skeleton Framework   examples/cms/app/models/usersModel.php   Download  
File: examples/cms/app/models/usersModel.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 10 years ago
Size: 1,175 bytes
 

Contents

Class file image Download
<?php

class usersModel {
    public $data = array(
            array(
                'id' => 1,
                'userid' => 'user1',
                'password' => 'user1',
                'access' => 'post',
                'fname' => 'Test',
                'lname' => 'One',
                ),
            array(
                'id' => 2,
                'userid' => 'user2',
                'password' => 'user2',
                'access' => 'post|admin',
                'fname' => 'Test',
                'lname' => 'Two',
                ),
            );
    protected $errmsg = '';
    
    function findAll(){
        $this->errmsg = '';
        return $this->data; 
    }
    
    function find($id){
        $this->errmsg = '';
        foreach ($this->data as $row) {
            if ($row['id'] == $id) {
                return $row; 
            }
        }
        return array();
    }
    
    function login($userid, $password) {

        $this->errmsg = '';
        if ($this->data) {
            foreach ($this->data as $row) {
                if ($row['userid'] == $userid) {
                    if ($row['password'] == $password) {
                        return $row;
                    } else {
                        $this->errmsg = 'password does not match.';
                    }
                    break;
                } else {
                    $this->errmsg = 'userid not found.';
                }
            }
        } else {
            $this->errmsg = 'no user data not found.';
        }
        return array();
    }
    
    function getErrorMsg(){
        return $this->errmsg;
    }
    
}