本文整理汇总了PHP中valid::digit方法的典型用法代码示例。如果您正苦于以下问题:PHP valid::digit方法的具体用法?PHP valid::digit怎么用?PHP valid::digit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类valid
的用法示例。
在下文中一共展示了valid::digit方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save(array $person = array(), $person_id = null)
{
$result = array('success' => false, 'error' => '');
$valid = true;
$person = $this->get_trimmed_allowed($person, array('space_id', 'email', 'x', 'y', 'active'));
if (isset($person['space_id']) && !valid::digit($person['space_id'])) {
$valid = false;
}
if (isset($person['email']) && !valid::email($person['email'])) {
$valid = false;
}
if (isset($person['x']) && !valid::numeric($person['x'])) {
$valid = false;
}
if (isset($person['y']) && !valid::numeric($person['y'])) {
$valid = false;
}
if (isset($person['active']) && !valid::digit($person['active'])) {
$valid = false;
}
if ($valid) {
if ($person_id) {
//UPDATE
$this->db->from('people')->set($person)->where(array('id' => (int) $person_id))->update();
$result['success'] = true;
} else {
// INSERT
$new_person = $this->db->from('people')->set($person)->insert();
$result['success'] = true;
$person_id = $new_person->insert_id();
}
$person = $this->db->select('people.*')->from('people')->where(array('id' => $person_id))->get();
$person = $this->result_as_array($person);
$result['person'] = $person;
} else {
$result['error'] = "The supplied data was invalid";
}
return $result;
}
示例2: valid_digit_test
public function valid_digit_test()
{
$this->assert_true_strict(valid::digit('123'))->assert_false_strict(valid::digit('abc'));
}
示例3: digit
/**
* Tests the valid::digit() function.
* @dataProvider digit_provider
* @group core.helpers.valid.digit
* @test
*/
public function digit($input_digit, $expected_result)
{
$result = valid::digit($input_digit);
$this->assertEquals($expected_result, $result);
}
示例4: edit
/**
* edit an item
*
* @param object $setup
* @return void
* @author Andy Bennett
*/
public function edit($setup = false)
{
// acl check
$data = array('action' => 'edit', 'name' => $this->name, 'role' => Steamauth::instance()->get_role());
Event::run('steamcore.aclcheck', $data);
// are we using a passed id or one POSTed
$id = isset($setup->id) ? $setup->id : $this->input->post('form_id');
// set up the defaults
$d = array('model' => $this->model, 'form_name' => $this->setup['name'] . '_edit', 'form_data' => array(), 'update' => valid::digit($id) ? $id : FALSE);
$setup = steamcore::array_object($d, $setup);
// try running the form, throw exception on error (shouldn't happen)
try {
steamform_helper::run_form($setup);
} catch (Exception $e) {
throw new Kohana_User_Exception('SteamCore Edit Error', $e->getMessage());
}
}