P4PHP API - 如何使用-f标志保存p4客户端?

时间:2011-08-11 15:52:16

标签: php api perforce perforce-client-spec

我正在使用P4PHP API构建一个GUI,允许用户批量创建/更新客户端规范。只要客户端被解锁,这就行得很好,但对于锁定的客户端,API没有获取-f标志(或者至少我认为不是)。尝试保存锁定的客户端时,我收到以下错误消息。这很奇怪,因为我有一个Python脚本使用Python p4 API做同样的事情并且它使用相同的行来保存客户端,但它确实选择了-f标志。我不知道该怎么做。

  

[错误]:'owner1'拥有的锁定客户端'php_test_client';使用-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 个答案:

答案 0 :(得分:1)

你还需要-i标志!

这有效:

$p4->input = $client;
$p4->run_client("-i","-f");