public function insert($data = null)
    {
        $currentIndex = $this->getFieldValue($this->getIndex());
        $fields = $this->getFields();
        $sql1 = '';
        $sql2 = '';
        $args = array();
        foreach ($fields as $field) {
            // if($this->getFieldValue($field, $data) !== NULL)
            if (in_array($field, $this->created_at_fileds)) {
                $this->{$field} = now();
            }
            $value = $this->getFieldValue($field, $data);
            $args[$field] = $value;
            $sql1 .= "`$field`, ";
            $sql2 .= ":$field, ";
        }
        if (!empty($sql1)) {
            $sql1 = substr($sql1, 0, -2);
            $sql2 = substr($sql2, 0, -2);
            if($currentIndex) {
                $this->db->removeCache($this->getCacheId($currentIndex));
            }
            return $this->db->insert('INSERT INTO `'.$this->table_name.'` ('.$sql1.') VALUES ('.$sql2.')', $args);
        }
        return false;
    }
public function insert($data = null)
    {
        $currentIndex = $this->getFieldValue($this->getIndex());
        $fields = $this->getFields();
        $sql1 = '';
        $sql2 = '';
        $args = array();
        foreach ($fields as $field) {
            // if($this->getFieldValue($field, $data) !== NULL)
            if (in_array($field, $this->created_at_fileds)) {
                $this->{$field} = now();
            }
            $value = $this->getFieldValue($field, $data);
            $args[$field] = $value;
            $sql1 .= "`$field`, ";
            $sql2 .= ":$field, ";
        }
        if (!empty($sql1)) {
            $sql1 = substr($sql1, 0, -2);
            $sql2 = substr($sql2, 0, -2);
            if($currentIndex) {
                $this->db->removeCache($this->getCacheId($currentIndex));
            }
            return $this->db->insert('INSERT INTO `'.$this->table_name.'` ('.$sql1.') VALUES ('.$sql2.')', $args);
        }
        return false;
    }
public function insert ( $ data = null ) { $ currentIndex = $ this -> getFieldValue ( $ this -> getIndex ( ) ) ; $ fields = $ this -> getFields ( ) ; $ sql1 = '' ; $ sql2 = '' ; $ args = array ( ) ; foreach ( $ fields as $ field ) { // if($this->getFieldValue($field, $data) !== NULL) if ( in_array ( $ field , $ this -> created_at_fileds ) ) { $ this -> { $ field } = now ( ) ; } $ value = $ this -> getFieldValue ( $ field , $ data ) ; $ args [ $ field ] = $ value ; $ sql1 .= "`$field`, " ; $ sql2 .= ":$field, " ; } if ( ! empty ( $ sql1 ) ) { $ sql1 = substr ( $ sql1 , 0 , - 2 ) ; $ sql2 = substr ( $ sql2 , 0 , - 2 ) ; if ( $ currentIndex ) { $ this -> db -> removeCache ( $ this -> getCacheId ( $ currentIndex ) ) ; } return $ this -> db -> insert ( 'INSERT INTO `' . $ this -> table_name . '` (' . $ sql1 . ') VALUES (' . $ sql2 . ')' , $ args ) ; } return false ; }
Inserta el modelo en la tabla

@param null $data
@return bool
Inserta el modelo en la tabla