本文整理汇总了PHP中Codes::prepareCodesForInsert方法的典型用法代码示例。如果您正苦于以下问题:PHP Codes::prepareCodesForInsert方法的具体用法?PHP Codes::prepareCodesForInsert怎么用?PHP Codes::prepareCodesForInsert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codes
的用法示例。
在下文中一共展示了Codes::prepareCodesForInsert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPrepareCodes
public function testPrepareCodes()
{
$C = new Codes();
$C->format = "ABC******";
// 9 characters + ',' will be 10 chars
$C->prefix = $C->setPrefix($C->format);
$C->num_random_chars = strlen($C->format) - strlen($C->prefix);
$C->fieldlength = 100;
// sets fieldlength artifically low just for test usually 32768
$num_codes = 101;
$codes = $C->generateMany($num_codes);
$code_length = strlen($codes[0]);
$prep = $C->prepareCodesForInsert($codes);
$c = ceil($num_codes * ($code_length + 1) / $C->fieldlength);
// echo "\n | first code : $codes[0] ";
// echo " | num_codes : $num_codes ";
// echo " | code_length : $code_length \n";
print_r($prep);
// we expect the number of strings of codes to be 11
$this->assertTrue(count($prep) == $c);
}
示例2: SforceEnterpriseClient
<?php
require './codes.php';
// contains the DB credentials and connection
require_once './Force.com-Toolkit-for-PHP/soapclient/SforceEnterpriseClient.php';
$mySforceConnection = new SforceEnterpriseClient();
$wsdl = './test.enterprise.wsdl.xml';
//$wsdl = './enterprise.wsdl.xml';
$mySforceConnection->createConnection($wsdl);
$mySforceConnection->login(USERNAME, PASSWORD . SECURITY_TOKEN);
$C = new Codes();
$codes = $C->generateMany($number_of_codes);
$prep = $C->prepareCodesForInsert($codes);
// echo 'Prefix : ' .$C->prefix .'<br />';
// echo '<pre>';
// print_r($codes);
// echo '</pre>';
/************************** INSERT DATA INTO SF **************************/
$records = array();
$i = 0;
foreach ($prep as $code) {
$records[$i] = new stdclass();
$records[$i]->Contract_Deal_Attribute__c = $cda;
$records[$i]->Voucher_Code__c = $code;
$i++;
}
$response = $mySforceConnection->create($records, 'External_Voucher_Code__c');
print_r(json_encode($response));