Primary changes return type from ResultSet to int for those requests that only return a record count. Also corrected a few other minor issues.

This commit is contained in:
Steve Ireland
2023-03-15 21:25:52 -04:00
parent 80b893a332
commit c5180ab614
16 changed files with 32 additions and 27 deletions

View File

@@ -48,15 +48,18 @@ class Tax_code extends Model
/**
* Gets information about the particular record
*/
public function get_info(int $tax_code_id): object
public function get_info(?int $tax_code_id): object
{
$builder = $this->db->table('tax_codes');
if($tax_code_id != null)
{
$builder = $this->db->table('tax_codes');
$builder->where('tax_code_id', $tax_code_id);
$builder->where('deleted', 0);
$query = $builder->get();
$builder->where('tax_code_id', $tax_code_id);
$builder->where('deleted', 0);
$query = $builder->get();
}
if($query->getNumRows() == 1) //TODO: ===
if($tax_code_id != null && $query->getNumRows() === 1)
{
return $query->getRow();
}
@@ -68,7 +71,7 @@ class Tax_code extends Model
//Get all the fields from the table
foreach($this->db->getFieldNames('tax_codes') as $field)
{
$tax_code_obj->$field = '';
$tax_code_obj->$field = null;
}
return $tax_code_obj;
}
@@ -191,7 +194,7 @@ class Tax_code extends Model
/**
* Gets rows
*/
public function get_found_rows(string $search): ResultInterface
public function get_found_rows(string $search): int
{
return $this->search($search, 0, 0, 'tax_code_name', 'asc', TRUE);
}