本文整理汇总了PHP中RequiredFields::getFields方法的典型用法代码示例。如果您正苦于以下问题:PHP RequiredFields::getFields方法的具体用法?PHP RequiredFields::getFields怎么用?PHP RequiredFields::getFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequiredFields
的用法示例。
在下文中一共展示了RequiredFields::getFields方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: put
public function put($id = null)
{
if (empty($id)) {
new Error("Safety Check ID cannot be empty");
}
$fields = array();
parse_str(file_get_contents("php://input"), $fields);
$result = RequiredFields::getFields(array('completed' => array('required' => true, 'regex' => '/^(0|1)$/')), $fields);
$fields = array();
foreach ($result['data'] as $key => $value) {
if (!empty($key) && !empty($value)) {
$fields[$key] = $value;
}
}
if (0 < count($fields)) {
$this->db->prepareUpdate($fields);
if ($this->db->update($this->tableName, $id)) {
$this->get($id);
} else {
new Error("Could not update safety check");
}
} else {
new Error("No values to update");
}
}
示例2: put
public function put($customerId = null, $carId = null)
{
if (empty($carId)) {
new Error("Car ID cannot be empty");
}
$fields = array();
parse_str(file_get_contents("php://input"), $fields);
$result = RequiredFields::getFields(array('owner' => array('regex' => '/^\\d+$/'), 'make' => array('regex' => '/^.{1,100}$/'), 'model' => array('regex' => '/^.{1,100}$/'), 'registration' => array('regex' => '/^[A-Z0-9]{1,6}$/')), $fields);
$fields = array();
foreach ($result['data'] as $key => $value) {
if (!empty($key) && !empty($value)) {
$fields[$key] = $value;
}
}
if (0 < count($fields)) {
$this->db->prepareUpdate($fields);
if ($this->db->update($this->tableName, $carId)) {
$this->get(array_key_exists('owner', $fields) ? $fields['owner'] : $customerId, $carId);
} else {
new Error("Could not update customer");
}
} else {
new Error("No values to update");
}
}
示例3: put
public function put($id = null)
{
if (empty($id)) {
new Error("Customer ID cannot be empty");
}
$fields = array();
parse_str(file_get_contents("php://input"), $fields);
$result = RequiredFields::getFields(array('firstname' => array('regex' => '/^.{1,30}$/'), 'lastname' => array('regex' => '/^.{1,30}$/'), 'address' => array('regex' => '/^.{1,100}$/'), 'city' => array('regex' => '/^.{1,50}$/'), 'state' => array('regex' => '/^.{1,20}$/'), 'postcode' => array('regex' => '/^\\d{4}$/')), $fields);
$fields = array();
foreach ($result['data'] as $key => $value) {
if (!empty($key) && !empty($value)) {
$fields[$key] = $value;
}
}
if (0 < count($fields)) {
$this->db->prepareUpdate($fields);
if ($this->db->update($this->tableName, $id)) {
$this->get($id);
} else {
new Error("Could not update customer");
}
} else {
new Error("No values to update");
}
}
示例4: put
public function put($id = null)
{
if (empty($id)) {
new Error("Item ID cannot be empty");
}
$fields = array();
parse_str(file_get_contents("php://input"), $fields);
$result = RequiredFields::getFields(array('invoice' => array('regex' => '/^\\d+$/'), 'amount' => array('regex' => '/^([\\d]*\\.[\\d]+|[\\d]+)$/'), 'comment' => array(), 'date' => array('regex' => '/^2\\d{3}\\-[01]\\d\\-[0-3]\\d$/')), $fields);
$fields = array();
foreach ($result['data'] as $key => $value) {
if (!empty($key) && !empty($value)) {
$fields[$key] = $value;
}
}
if (0 < count($fields)) {
$this->db->prepareUpdate($fields);
if ($this->db->update($this->tableName, $id)) {
$this->get($id);
} else {
new Error("Could not update payment");
}
} else {
new Error("No values to update");
}
}
示例5: put
public function put($id = null)
{
if (empty($id)) {
new Error("Item ID cannot be empty");
}
$fields = array();
parse_str(file_get_contents("php://input"), $fields);
$result = RequiredFields::getFields(array('description' => array('regex' => '/^.{1,100}$/'), 'defaultCost' => array('regex' => '/^[-+]?([\\d]*\\.[\\d]+|[\\d]+)$/'), 'defaultQuantity' => array('regex' => '/^[-+]?([\\d]*\\.[\\d]+|[\\d]+)$/'), 'comment' => array('regex' => '/^(0|1)$/'), 'active' => array('regex' => '/^(0|1)$/')), $fields);
$fields = array();
foreach ($result['data'] as $key => $value) {
if (!empty($key) && !empty($value)) {
$fields[$key] = $value;
}
}
if (0 < count($fields)) {
$this->db->prepareUpdate($fields);
if ($this->db->update($this->tableName, $id)) {
$this->get($id);
} else {
new Error("Could not update item");
}
} else {
new Error("No values to update");
}
}
示例6: post
public function post()
{
$result = RequiredFields::getFields(array('owner' => array('required' => true, 'regex' => '/^\\d+$/'), 'car' => array('required' => true, 'regex' => '/^\\d+$/'), 'odo' => array('required' => true, 'regex' => '/^\\d{1,6}$/'), 'safetyCheck' => array('required' => true, 'regex' => '/^\\d+$/')), $_POST);
if ($result['error']) {
new Error("Invalid values passed", $result['data']);
} else {
$this->db->prepareInsert($result['data']);
if ($this->db->insert($this->tableName)) {
$this->get($this->db->lastId());
} else {
new Error("Error inserting service record");
}
}
}
示例7: post
public function post()
{
$result = RequiredFields::getFields(array('service' => array('required' => true, 'regex' => '/^\\d+$/'), 'bankDetails' => array('regex' => '/^(0|1)$/')), $_POST);
if ($result['error']) {
new Error("Invalid values passed", $result['data']);
} else {
$this->db->prepareInsert($result['data']);
if ($this->db->insert($this->tableName)) {
$this->get($this->db->lastId());
//new Respond(array('id' => $this->db->lastId()));
} else {
new Error("Error inserting customer record");
}
}
}