The get_value method check the existence of a property with array_key_exists
This commit is contained in:
parent
9c3d253456
commit
843a476d0b
6 changed files with 30 additions and 25 deletions
|
@ -404,21 +404,23 @@ class Admins_model extends EA_Model {
|
||||||
|
|
||||||
// Check whether the admin record exists.
|
// Check whether the admin record exists.
|
||||||
$result = $this->db->get_where('users', ['id' => $admin_id]);
|
$result = $this->db->get_where('users', ['id' => $admin_id]);
|
||||||
if ($result->num_rows() == 0)
|
|
||||||
|
if ($result->num_rows() === 0)
|
||||||
{
|
{
|
||||||
throw new Exception('The record with the given id does not exist in the '
|
throw new Exception('The record with the given id does not exist in the '
|
||||||
. 'database: ' . $admin_id);
|
. 'database: ' . $admin_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the required field name exist in database.
|
// Check if the required field name exist in database.
|
||||||
$provider = $result->row_array();
|
$row_data = $result->row_array();
|
||||||
if ( ! isset($provider[$field_name]))
|
|
||||||
|
if ( ! array_key_exists($field_name, $row_data))
|
||||||
{
|
{
|
||||||
throw new Exception('The given $field_name argument does not exist in the '
|
throw new Exception('The given $field_name argument does not exist in the '
|
||||||
. 'database: ' . $field_name);
|
. 'database: ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $provider[$field_name];
|
return $row_data[$field_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -352,13 +352,13 @@ class Appointments_model extends EA_Model {
|
||||||
|
|
||||||
if ($this->db->get_where('appointments', ['id' => $appointment_id])->num_rows() == 0)
|
if ($this->db->get_where('appointments', ['id' => $appointment_id])->num_rows() == 0)
|
||||||
{
|
{
|
||||||
throw new Exception('The record with the provided id '
|
throw new Exception('The record with the provided ID does not exist in the database: '
|
||||||
. 'does not exist in the database: ' . $appointment_id);
|
. $appointment_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$row_data = $this->db->get_where('appointments', ['id' => $appointment_id])->row_array();
|
$row_data = $this->db->get_where('appointments', ['id' => $appointment_id])->row_array();
|
||||||
|
|
||||||
if ( ! isset($row_data[$field_name]))
|
if ( ! array_key_exists($field_name, $row_data))
|
||||||
{
|
{
|
||||||
throw new Exception('The given field name does not exist in the database: ' . $field_name);
|
throw new Exception('The given field name does not exist in the database: ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
|
@ -331,10 +331,10 @@ class Customers_model extends EA_Model {
|
||||||
|
|
||||||
$row_data = $this->db->get_where('users', ['id' => $customer_id])->row_array();
|
$row_data = $this->db->get_where('users', ['id' => $customer_id])->row_array();
|
||||||
|
|
||||||
if ( ! isset($row_data[$field_name]))
|
if ( ! array_key_exists($field_name, $row_data))
|
||||||
{
|
{
|
||||||
throw new Exception('The given $field_name argument does not'
|
throw new Exception('The given $field_name argument does not exist in the database: '
|
||||||
. 'exist in the database: ' . $field_name);
|
. $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$customer = $this->db->get_where('users', ['id' => $customer_id])->row_array();
|
$customer = $this->db->get_where('users', ['id' => $customer_id])->row_array();
|
||||||
|
|
|
@ -493,18 +493,18 @@ class Providers_model extends EA_Model {
|
||||||
|
|
||||||
if ($result->num_rows() == 0)
|
if ($result->num_rows() == 0)
|
||||||
{
|
{
|
||||||
throw new Exception('The record with the $provider_id argument does not exist in '
|
throw new Exception('The record with the $provider_id argument does not exist in the database: '
|
||||||
. 'the database: ' . $provider_id);
|
. $provider_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$provider = $result->row_array();
|
$row_data = $result->row_array();
|
||||||
|
|
||||||
if ( ! isset($provider[$field_name]))
|
if ( ! isset($row_data[$field_name]))
|
||||||
{
|
{
|
||||||
throw new Exception('The given $field_name argument does not exist in the database: ' . $field_name);
|
throw new Exception('The given $field_name argument does not exist in the database: ' . $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $provider[$field_name];
|
return $row_data[$field_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -480,21 +480,23 @@ class Secretaries_model extends EA_Model {
|
||||||
|
|
||||||
// Check whether the secretary record exists.
|
// Check whether the secretary record exists.
|
||||||
$result = $this->db->get_where('users', ['id' => $secretary_id]);
|
$result = $this->db->get_where('users', ['id' => $secretary_id]);
|
||||||
if ($result->num_rows() == 0)
|
|
||||||
|
if ($result->num_rows() === 0)
|
||||||
{
|
{
|
||||||
throw new Exception('The record with the given id does not exist in the '
|
throw new Exception('The record with the given id does not exist in the '
|
||||||
. 'database: ' . $secretary_id);
|
. 'database: ' . $secretary_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the required field name exist in database.
|
// Check if the required field name exist in database.
|
||||||
$provider = $result->row_array();
|
$row_data = $result->row_array();
|
||||||
if ( ! isset($provider[$field_name]))
|
|
||||||
|
if ( ! array_key_exists($field_name, $row_data))
|
||||||
{
|
{
|
||||||
throw new Exception('The given $field_name argument does not exist in the '
|
throw new Exception('The given $field_name argument does not exist in the database: '
|
||||||
. 'database: ' . $field_name);
|
. $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $provider[$field_name];
|
return $row_data[$field_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -303,13 +303,14 @@ class Services_model extends EA_Model {
|
||||||
}
|
}
|
||||||
|
|
||||||
$row_data = $this->db->get_where('services', ['id' => $service_id])->row_array();
|
$row_data = $this->db->get_where('services', ['id' => $service_id])->row_array();
|
||||||
if ( ! isset($row_data[$field_name]))
|
|
||||||
|
if ( ! array_key_exists($field_name, $row_data))
|
||||||
{
|
{
|
||||||
throw new Exception('The given $field_name argument does not exist in the database: ' . $field_name);
|
throw new Exception('The given $field_name argument does not exist in the database: '
|
||||||
|
. $field_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
$setting = $this->db->get_where('services', ['id' => $service_id])->row_array();
|
return $row_data[$field_name];
|
||||||
return $setting[$field_name];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue