Welcome Guest, Not a member yet? Register   Sign In
Strange issue with validation libraries
#15

[eluser]daweb[/eluser]
Ok tonanbarbarian, here I am.

Language file is autoloaded from autoload.php and it runs fine in all my app.

This is the setting model (set), there are just queries to my db tables.

Code:
<?php
class settings_model extends Model {

    function __construct()
    {
        parent::Model();
    }
    
    function list_items($table = NULL, $extraQuery = NULL, $order = 'name')
    {
        $this->db->orderby($order, 'desc');
        if($table == 'categories' && $extraQuery) $this->db->where('id', $extraQuery);
        if($table == 'details' && $extraQuery) $this->db->where('option_cod', $extraQuery);
        if($table == 'details_options' && $extraQuery) $this->db->where('detail_cod', $extraQuery);

        if($table == 'typologies') $this->db->where('typologies.category_cod', $extraQuery);
                
        return $this->db->get($table);
    }
    
    function list_entries()
    {
        $this->db->select('*, categories.name as categoryName, typologies.name as typologyName, entries.id as entryId, entries.status as entryStatus');
        $this->db->where(array('entries.status >=' => 0));
        $this->db->join('categories', 'categories.id = entries.category_cod');
        $this->db->join('typologies', 'typologies.id = entries.typology_cod');
        $this->db->orderby('created_date');
        return $this->db->get('entries');
    }    

        
    function list_one_item($table, $id)
    {
        $this->db->where('id', $id);
        $query = $this->db->get($table);
        if($query->num_rows() <= 0)
        {
            return FALSE;
        }
        return $query->row();
    }
    
        
    function insert_new_item($table = NULL, $title, $title_url, $field = NULL, $value = NULL, $serialized = NULL)
    {
        $title = $this->db->escape_str($title);
        
        $title = ucfirst($title);
        $title_url = strtolower($title_url);
        $title = ascii_to_entities($title);
        $data_stack = array('name' => $title, 'url' => $title_url, 'created' => time(), 'lastedit' => time(), 'status' => 1);
        
        if(!is_null($value)) $data_stack[$field] = $value;
        if(!is_null($serialized)) $data_stack['type_value'] = $serialized;
    
        if(!empty($title))
        {
            $this->db->insert($table, $data_stack);
        }
    }
    
    
    function delete_items($item, $table)
    {
        $this->db->where('id', $item);
        $this->db->delete($table);
        // ottimizza la tabella
        $this->dbutil->optimize_table($table);
    }

    function edit_items($post, $item, $table)
    {
        $title = ascii_to_entities($post['title'][$item]);
        
        $data_stack = array(
                      'name' => $this->db->escape_str($title),
                      'url' => $this->db->escape_str($post['url_title'][$item]),
                      'lastedit' => time(),
                      'status' => $post['status'][$item]
                         );
        $this->db->where('id', $item);
        $this->db->update($table, $data_stack);
    }

    function unique_record($value)
    {
        $this->db->where('url', $value);
        if($this->table == 'typologies')
        {
            $this->db->where('category_cod', $this->idCategory);
        }
        if($this->table == 'details_options')
        {
            $this->db->where('detail_cod', $this->detailCod);
        }
        if($this->table == 'details')
        {
            $this->db->where('option_cod', $this->idCategory);
        }
        
        return $this->db->get($this->table);
    }
    
    function lastInsertItem($id)
    {
        $this->db->where('id', $id);
        return $this->db->get($this->table)->row();
    }
    
    function update_options_structure($options, $category, $typology, $emptyArray = NULL)
    {
        $data_stack = array();
        $data_stack['category_cod'] = $category;
        if(is_null($emptyArray))
        {
            foreach($options as $key => $value)
            {
                $data_stack['typology_cod'] = $key;
            
                $this->db->delete('options_structure', array('category_cod' => $category, 'typology_cod' => $key));
                foreach($value as $valore)
                {
                    echo $this->db->last_query();
                    $data_stack['option_cod'] = $valore;
                    $this->db->insert('options_structure', $data_stack);
                }
            }
        }
        else
        {
            $this->db->delete('options_structure', array('category_cod' => $category, 'typology_cod' => $typology));
        }
    }
    
    function updateMemoField($value, $id)
    {
        $data_stack = array('type_value' => $value);
        $this->db->where('id', $id);
        $this->db->update('details', $data_stack, 1);
    }
}
?&gt;


Messages In This Thread
Strange issue with validation libraries - by El Forum - 02-11-2008, 03:35 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 03:48 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 04:14 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 04:15 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 04:17 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 04:19 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 04:22 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 04:38 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 04:44 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 04:48 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 05:00 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 05:23 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 05:27 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 06:03 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 06:11 AM
Strange issue with validation libraries - by El Forum - 02-11-2008, 02:36 PM



Theme © iAndrew 2016 - Forum software by © MyBB