本文整理匯總了PHP中opToolkit::unifyEOLCharacter方法的典型用法代碼示例。如果您正苦於以下問題:PHP opToolkit::unifyEOLCharacter方法的具體用法?PHP opToolkit::unifyEOLCharacter怎麽用?PHP opToolkit::unifyEOLCharacter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類opToolkit
的用法示例。
在下文中一共展示了opToolkit::unifyEOLCharacter方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
public function run()
{
$path = $this->options['dir'] . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . $this->options['name'] . '.sql';
if (!file_exists($path)) {
throw new RuntimeException('The specified sql doesn\'t exist.');
}
$db = $this->getDatabaseManager()->getDatabase('doctrine');
$this->conn = $db->getDoctrineConnection();
$this->conn->beginTransaction();
$this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
// for mysql
$sql = opToolkit::unifyEOLCharacter($this->parseSql($path));
$queries = explode("\n", $sql);
try {
$this->executeQueries($queries);
$this->conn->commit();
} catch (Exception $e) {
$this->conn->rollback();
$this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
// for mysql
throw $e;
}
$this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
// for mysql
}
示例2: validate
public function validate($validator, $value, $arguments = array())
{
$value = opToolkit::unifyEOLCharacter($value);
$list = array_map('trim', explode("\n", $value));
$list = array_unique($list);
foreach ($list as $item) {
if (!preg_match('/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$/', $item)) {
throw new sfValidatorError($validator, 'invalid');
}
}
return implode("\n", $list);
}
示例3: validate
public function validate($validator, $values, $arguments = array())
{
$values = $values + array('pc' => array(), 'mobile' => array(), 'invalid' => array());
$inputList = explode("\n", opToolkit::unifyEOLCharacter($values['mail_address']));
$inputList = array_unique(array_map('trim', $inputList));
foreach ($inputList as $value) {
try {
$result = parent::validate($validator, array('mail_address' => $value));
if (!empty($result['pc_address'])) {
$values['pc'][] = $result['pc_address'];
} elseif (!empty($result['mobile_address'])) {
$values['mobile'][] = $result['mobile_address'];
}
} catch (sfValidatorError $e) {
$values['invalid'][] = $value;
}
}
if (empty($values['pc']) && empty($values['mobile'])) {
throw new sfValidatorError($validator, 'All of the inputted E-mail addresses are invalid.');
}
return $values;
}