<?php
//--Class Person--------------------------
//--PK of Person ::
//    1. personId

class deptref extends clsDB{

var 
$result;

var 
$drId;
var 
$deptId;
var 
$deptrefId;


function 
deptref(&$c){
    
$this->c=$c->c;
    
$this->DB=$c->db;
}
function 
Save(){
    if (
$this->status==1){
        
$sql "insert into deptref values(
            '$this->drId',
             '$this->deptId',
             '$this->deptrefId')"
;
    }else {
        
$sql "update deptref set 
            deptId='$this->deptId', 
            deptrefId='$this->deptrefId'
            where drId='$this->drId'"
;
    }
    echo 
"sql = ".$sql."<br>";
    return 
$this->Dml($sql);
}
function 
GetNextCode(){
    
$this->SetQuery("select max(drId) as num from deptref");
    if (
$result=$this->GetResult()) {
        return 
$result['num']+1;
    }else{
        return 
1;    
    }
}
function 
GetRecord(){
    
$numFields $this->NumField();
    
$row $this->GetResult();
    if (
$row){
        for (
$i=0$i<$numFields$i++){
            eval(
"\$this->".mysql_field_name($this->rs$i)."=\$row['".mysql_field_name($this->rs$i)."'];");
        }
        return 
true;
    }else{    
// clear value of Member;
        
for ($i=0$i<$numFields$i++){
            eval(
"\$this->".mysql_field_name($this->rs$i)."='';");
        }
        return 
false;
    }
}
//****************** You can add new functions below **********************//
function SearchBydeptIddeptrefId($xKey,$yKey){
    if (
$this->SetQuery("select * from deptref where deptId='$xKey' and deptrefId='$yKey' ")){ 
        return 
1;
    }else {
        return 
0;
    }
}
function 
searchBydeptRefId($xKey){
    if (
$this->SetQuery("select * from deptref where deptrefId='$xKey'")){ 
        return 
1;
    }else {
        return 
0;
    }
}
function 
searchBydeptId($xKey){
    if (
$this->SetQuery("select * from deptref where deptId='$xKey'")){ 
        return 
1;
    }else {
        return 
0;
    }
}
function 
searchcountBydeptId($xKey){
    
$this->SetQuery("select count(deptId) as num from deptref where deptId='$xKey'"); 
    if (
$result=$this->GetResult()) {
        return 
$result['num'];
    }
}
function 
deleteDept($xKey){
    return 
$this->Dml("delete from deptref where deptId='$xKey'");
}
//--End class Person--

?>