Error while browsing www.grahasti.com
Parse error: syntax error, unexpected T_STRING in /customers/e/8/f/grahasti.com/httpd.www/apps/home/Lib/Model/UserModel.class.php on line 1 

Class content:

<?php
class UserModel extends Model 
{
protected $tableName='user';  var $uid;


public function getUserByMap($map = array(), $field = '*', $limit = '', $order = '', $is_find_page = true)
{

if ($is_find_page)
   {
            return $this->where($map)->field($field)->order($order)->findPage($limit);

}
else
{
            return $this->where($map)->field($field)->order($order)->limit($limit)->findAll();

}
}



public function getUserList($map = '', $show_dept = false, $show_user_group = false, $field = '*', $order = 'uid ASC', $limit = 30)
{
        $res  = $this->where($map)->field($field)->order($order)->findPage($limit);


$uids = getSubByKey($res['data'], 'uid');




if ($show_dept) 
{
        }



if ($show_user_group) 
{
            $temp_user_group = model('UserGroup')->getUserGroupByUid($uids);



array($uid => $user_group)

$user_group = array();

foreach($temp_user_group as $v)
 {

$user_group[$v['uid']][] = $v;

}
unset($temp_user_group);
foreach($res['data'] as $k => $v) 
{
$res['data'][$k]['user_group'] = isset($user_group[$v['uid']]) ? $user_group[$v['uid']] : array();

}
}
return $res;

}


public function deleteUser($uids) 
{
$uids = is_array($uids) ? $uids : explode(',', $uids);
foreach($uids as $k => $v) 
{
if ( !is_numeric($v) ) unset($uids[$k]);
}
if ( empty($uids) ) return false;
$map['uid'] = array('in', $uids);

M('user')->where($map)->delete();

return true;
    }


function upDate($type){
        return $this->$type();

}


private function upbase( )
{
$nickname = t($_POST['nickname']);

if(!$nickname)
{

$data['message'] = 
'昵称不能为空';
$data['boolen']  = 0;

return $data;
}
if( !isLegalUsername($nickname) )
{

$data['message'] = 
'昵称格式不正确';
$data['boolen']  = 0;
return $data;
}
if( M('user')->where("uname='{$nickname}' AND uid!={$this->uid}")->find() )
{
$data['message'] = '昵称已被人使用';
$data['boolen']  = 0;
return $data;
}
$data['province'] = intval( $_POST['area_province'] );
$data['uname']    = $nickname;
$data['city']     = intval( $_POST['area_city'] );
$data['location'] =  getLocation($data['province'],$data['city']);
$data['sex']      = intval( $_POST['sex'] );

M('user')->where("uid={$this->uid}")->data($data)->save();

$data['message'] = '更新完成';

$data['boolen']  = 1;

return $data;
}
protected function data_field($module = '')
{
$list = $this->table(C('DB_PREFIX').'user_set')->where("status=1")->findall();

foreach ($list as $value)
{
$data[$value['module']][$value['fieldkey']] = $value['fieldname'];

}

return ($module)?$data[$module]:$data;
    }


}
?>

Kindly suggest how to resolve this.

Member Avatar for diafol
protected $tableName='user';

Don't think you can apply a value outside a method. I'm a noob at OOP, but I've been using the __construct() method to apply default values:

protected $tableName;

public __construct(){
  $this->tableName = 'user';
}

I don't know if this is the right way though...

OR you could pass the table name as a parameter if it's dynamic:

public __construct($table){
  $this->tableName = $table;
}

and then

$um = new UserModel('user');

Yes, you can give it a value. Unless perhaps he's on an older version.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.