2011-08-11 56 views
0

我正在使用P4PHP API構建一個允許用戶批量創建/更新客戶端規格的GUI。只要客戶端解鎖,這個工作就很好,但對於鎖定的客戶端,API不會選擇-f標誌(或者至少我不認爲它是)。嘗試保存已鎖定的客戶端時,出現以下錯誤消息。這很奇怪,因爲我有一個Python腳本,它使用Python p4 API執行幾乎相同的操作,它使用相同的行來保存客戶端,但它確實取得了-f標誌。我不知道這裏要做什麼。P4PHP API - 如何使用-f標誌保存p4客戶端?

[錯誤]:鎖定客戶端'php_test_client'擁有'owner1';使用-f到 強制更新。

這裏是我的PHP代碼:

$p4 = new P4(); //instantiate p4 object 
$p4->port = 'perforce:1666'; //set p4 port 
$p4->user = $pUser; //set p4 user 
try{ 
    $p4->connect(); 
    $p4->run_login($pPass); //login with provided p4 pass 
    $client = $p4->fetch_client($cNameSub); 
    echo "client fetched: " . $cNameSub ."\n"; 
    $client['Client']= $cNameSub; 
    $client['Description']= $cDescrSub; 
    $client['Owner']= $cOwnerSub; 
    $client['Host']= $cHostSub; 
    $client['Root']= $cRootSub; 
    $client['View']= $cViewArraySub; 
    $client['Options']= $cOptSub; 

    $p4->save_client($client,"-f"); 
    $p4->disconnect(); 

    echo "client" . $cNameSub . " created successfully \n\n"; 
} catch (P4_Exception $e) { 
    // output errors 
    echo $e->getMessage() . "\n"; 
    foreach ($p4->errors as $error) { 
      echo "Error: $error\n"; 
    } 
    //TODO: log errors in db 
} 

我也試過保存客戶端以下行,但它不工作之一:

//try1 
$p4->input = $client; 
$p4->run("client", "-f"); 
//try2 
$p4->run("client", "-f", $client); 
//try3 
$p4->input = $client; 
$p4->run_client("-f"); 

回答

1

您需要-i旗也!

這工作:

$p4->input = $client; 
$p4->run_client("-i","-f"); 
相關問題