Microweber\Utils\Database::map_array_to_table PHP Method

map_array_to_table() public method

Returns an array that contains only keys that has the same names as the table fields from the database.
public map_array_to_table ( $table, $array ) : array
return array
    public function map_array_to_table($table, $array)
    {
        $arr_key = crc32($table) + crc32(serialize($array));
        if (isset($this->table_fields[$arr_key])) {
            return $this->table_fields[$arr_key];
        }
        if (empty($array)) {
            return false;
        }
        $fields = $this->get_fields($table);
        if (is_array($fields)) {
            foreach ($fields as $field) {
                $field = strtolower($field);
                if (isset($array[$field])) {
                    if ($array[$field] != false) {
                        $array_to_return[$field] = $array[$field];
                    }
                    if ($array[$field] == 0) {
                        $array_to_return[$field] = $array[$field];
                    }
                }
            }
        }
        if (!isset($array_to_return)) {
            return false;
        } else {
            $this->table_fields[$arr_key] = $array_to_return;
        }
        return $array_to_return;
    }