本文整理汇总了PHP中PSU::randomString方法的典型用法代码示例。如果您正苦于以下问题:PHP PSU::randomString方法的具体用法?PHP PSU::randomString怎么用?PHP PSU::randomString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PSU
的用法示例。
在下文中一共展示了PSU::randomString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRandomString
function testRandomString()
{
$this->assertEquals(preg_match('/^[A-Za-z0-9]{8}$/', PSU::randomString(8)), 1, 'Length test: 8');
$this->assertEquals(preg_match('/^[A-Za-z0-9]{20}$/', PSU::randomString(20)), 1, 'Length test: 20');
$this->assertEquals(preg_match('/^[0-9]{20}$/', PSU::randomString(20, '0123456789')), 1, 'Pattern test (numbers)');
$this->assertEquals(preg_match('/^A{20}$/', PSU::randomString(20, 'A')), 1, 'Pattern test (letter A)');
$s = PSU::randomString(62, null, false);
$len = strlen($s);
$found = array();
for ($i = 0; $i < $len; $i++) {
$c = $s[$i];
$found[$c] = true;
}
$this->assertTrue(count($found) === 62, 'no duplicates');
}
示例2: insertSABNSTU
/**
* insert id/pin data
*/
public function insertSABNSTU()
{
// insert sabnstu data
// use commonapplicationClientID as the SABNSTU_ID
// generate a random pin using PSUTools
// first check sabiden to see if person already has an application
$aidm = $this->checkSABIDEN($this->commonapplicantclientid);
if ($aidm) {
psu::puke("This person, Client ID: " . $this->commonapplicantclientid . " is already in sabiden.");
}
if (!$aidm) {
$aidm = PSU::db('banner')->GetOne("SELECT sabaseq.nextval FROM dual");
}
$pin = PSU::randomString(6, "1234567890");
$client_id = $this->commonapplicantclientid;
$sql = "INSERT INTO sabnstu (\n\t\t\t\t\t\t\t\tsabnstu_id,\n\t\t\t\t\t\t\t\tsabnstu_aidm,\n\t\t\t\t\t\t\t\tsabnstu_locked_ind,\n\t\t\t\t\t\t\t\tsabnstu_pin,\n\t\t\t\t\t\t\t\tsabnstu_activity_date\n\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\tlpad(:client_id,9,'0'),\n\t\t\t\t\t\t\t\t:aidm,\n\t\t\t\t\t\t\t\t'N',\n\t\t\t\t\t\t\t\t:pin,\n\t\t\t\t\t\t\t\tsysdate\n\t\t\t\t\t\t\t)";
$rs = PSU::db('banner')->Execute($sql, compact('client_id', 'aidm', 'pin'));
if ($rs) {
$successfully_moved_to_banner = true;
} else {
$successfully_moved_to_banner = false;
psu::puke($client_id . " Failed trying to insert into Banner table SABNSTU.");
}
return $successfully_moved_to_banner;
}