mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-06-01 20:29:29 +00:00
- Changed helper and language autoload
- Changed language config - Removed never used constants - Changed rest_language in rest config file - Adapted models that where extending FHC_Model - Adapted code to load hlp_return_object - Adapted code to use exit status codes constants
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
class DB_Model extends FHC_Model
|
||||
class DB_Model extends CI_Model
|
||||
{
|
||||
// Default schema used by the models
|
||||
const DEFAULT_SCHEMA = 'public';
|
||||
@@ -64,7 +64,7 @@ class DB_Model extends FHC_Model
|
||||
public function insert($data)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
|
||||
// If this table has UDF and the validation of them is ok
|
||||
if (isError($validate = $this->_manageUDFs($data, $this->dbTable))) return $validate;
|
||||
@@ -100,7 +100,7 @@ class DB_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return error($this->db->error(), EXIT_DATABASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,8 +114,8 @@ class DB_Model extends FHC_Model
|
||||
public function update($id, $data)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->pk)) return error(EXIT_MODEL, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
|
||||
// If this table has UDF and the validation of them is ok
|
||||
if (isError($validate = $this->_manageUDFs($data, $this->dbTable, $id))) return $validate;
|
||||
@@ -148,7 +148,7 @@ class DB_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return error($this->db->error(), EXIT_DATABASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,8 +161,8 @@ class DB_Model extends FHC_Model
|
||||
public function delete($id)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
if (is_null($this->pk)) return error(EXIT_MODEL, FHC_NOPK);
|
||||
|
||||
$tmpId = $id;
|
||||
|
||||
@@ -190,7 +190,7 @@ class DB_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return error($this->db->error(), EXIT_DATABASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,8 +203,8 @@ class DB_Model extends FHC_Model
|
||||
public function load($id = null)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->pk)) return error(FHC_MODEL_ERROR, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->pk)) return error(EXIT_MODEL, FHC_NOPK);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
|
||||
$tmpId = $id;
|
||||
|
||||
@@ -232,7 +232,7 @@ class DB_Model extends FHC_Model
|
||||
public function loadWhere($where = null)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
|
||||
// Execute query
|
||||
$result = $this->db->get_where($this->dbTable, $where);
|
||||
@@ -245,7 +245,7 @@ class DB_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
return error($this->db->error(), FHC_DB_ERROR);
|
||||
return error($this->db->error(), EXIT_DATABASE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ class DB_Model extends FHC_Model
|
||||
public function loadTree($mainTable, $sideTables, $where = null, $sideTablesAliases = null)
|
||||
{
|
||||
// Check class properties
|
||||
if (is_null($this->dbTable)) return error(FHC_MODEL_ERROR, FHC_NODBTABLE);
|
||||
if (is_null($this->dbTable)) return error(EXIT_MODEL, FHC_NODBTABLE);
|
||||
|
||||
// List of tables on which it will work
|
||||
$tables = array_merge(array($mainTable), $sideTables);
|
||||
@@ -405,7 +405,7 @@ class DB_Model extends FHC_Model
|
||||
|| is_null($cond)
|
||||
|| !in_array($type, array('', 'LEFT', 'RIGHT', 'OUTER', 'INNER', 'LEFT OUTER', 'RIGHT OUTER')))
|
||||
{
|
||||
return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
return error(EXIT_MODEL, EXIT_MODEL);
|
||||
}
|
||||
|
||||
$this->db->join($joinTable, $cond, $type);
|
||||
@@ -421,7 +421,7 @@ class DB_Model extends FHC_Model
|
||||
public function addOrder($field = null, $type = 'ASC')
|
||||
{
|
||||
// Check class properties and parameters
|
||||
if (is_null($field) || !in_array($type, array('ASC', 'DESC'))) return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
if (is_null($field) || !in_array($type, array('ASC', 'DESC'))) return error(EXIT_MODEL, EXIT_MODEL);
|
||||
|
||||
$this->db->order_by($field, $type);
|
||||
|
||||
@@ -436,7 +436,7 @@ class DB_Model extends FHC_Model
|
||||
public function addSelect($select, $escape = true)
|
||||
{
|
||||
// Check class properties and parameters
|
||||
if (is_null($select) || $select == '') return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
if (is_null($select) || $select == '') return error(EXIT_MODEL, EXIT_MODEL);
|
||||
|
||||
$this->db->select($select, $escape);
|
||||
|
||||
@@ -461,7 +461,7 @@ class DB_Model extends FHC_Model
|
||||
public function addLimit($start = null, $end = null)
|
||||
{
|
||||
// Check class properties and parameters
|
||||
if (!is_numeric($start) || (is_numeric($start) && $start <= 0)) return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
if (!is_numeric($start) || (is_numeric($start) && $start <= 0)) return error(EXIT_MODEL, EXIT_MODEL);
|
||||
|
||||
if (is_numeric($end) && $end > $start)
|
||||
{
|
||||
@@ -485,7 +485,7 @@ class DB_Model extends FHC_Model
|
||||
$tmpTable = trim($table);
|
||||
|
||||
// Check parameters
|
||||
if (isEmptyString($tmpTable)) return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
if (isEmptyString($tmpTable)) return error(EXIT_MODEL, EXIT_MODEL);
|
||||
|
||||
if (!isEmptyString($alias))
|
||||
{
|
||||
@@ -509,7 +509,7 @@ class DB_Model extends FHC_Model
|
||||
|| (is_array($fields) && count($fields) == 0)
|
||||
|| (is_string($fields) && $fields == ''))
|
||||
{
|
||||
return error(FHC_MODEL_ERROR, FHC_MODEL_ERROR);
|
||||
return error(EXIT_MODEL, EXIT_MODEL);
|
||||
}
|
||||
|
||||
$this->db->group_by($fields);
|
||||
@@ -772,7 +772,7 @@ class DB_Model extends FHC_Model
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = error($this->db->error(), FHC_DB_ERROR);
|
||||
$result = error($this->db->error(), EXIT_DATABASE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user