public function __calculateSaveDownRows()
    {
        if (!$this->_columns) {
            foreach (get_object_vars($this) as $potential_column => $discard) {
                switch ($potential_column) {
                    case 'table':
                    case substr($potential_column, 0, 1) == "_":
                        // Not a valid column
                        break;
                    default:
                        $this->_columns[] = $potential_column;
                        break;
                }
            }
        }

        // reorder the columns to match get_class_schema
        //TODO: Write test to verify that this works right.
        foreach ($this->getClassSchema() as $schemaKey => $dontCare) {
            if (in_array($schemaKey, $this->_columns)) {
                $sortedColumns[$schemaKey] = $schemaKey;
            }
        }
        foreach ($this->_columns as $column) {
            if (!isset($sortedColumns[$column])) {
                $class_name = get_called_class();
                throw new Exception("No type hinting/docblock found for '{$column}' in '{$class_name}'.", E_USER_WARNING);
            }
        }

        $this->_columns = array_values($sortedColumns);

        // Return sorted columns.
        return $this->_columns;
    }
public function __calculateSaveDownRows()
    {
        if (!$this->_columns) {
            foreach (get_object_vars($this) as $potential_column => $discard) {
                switch ($potential_column) {
                    case 'table':
                    case substr($potential_column, 0, 1) == "_":
                        // Not a valid column
                        break;
                    default:
                        $this->_columns[] = $potential_column;
                        break;
                }
            }
        }

        // reorder the columns to match get_class_schema
        //TODO: Write test to verify that this works right.
        foreach ($this->getClassSchema() as $schemaKey => $dontCare) {
            if (in_array($schemaKey, $this->_columns)) {
                $sortedColumns[$schemaKey] = $schemaKey;
            }
        }
        foreach ($this->_columns as $column) {
            if (!isset($sortedColumns[$column])) {
                $class_name = get_called_class();
                throw new Exception("No type hinting/docblock found for '{$column}' in '{$class_name}'.", E_USER_WARNING);
            }
        }

        $this->_columns = array_values($sortedColumns);

        // Return sorted columns.
        return $this->_columns;
    }
public function __calculateSaveDownRows ( ) { if ( ! $ this -> _columns ) { foreach ( get_object_vars ( $ this ) as $ potential_column => $ discard ) { switch ( $ potential_column ) { case 'table' : case substr ( $ potential_column , 0 , 1 ) == "_" : // Not a valid column break ; default : $ this -> _columns [ ] = $ potential_column ; break ; } } } // reorder the columns to match get_class_schema //TODO: Write test to verify that this works right. foreach ( $ this -> getClassSchema ( ) as $ schemaKey => $ dontCare ) { if ( in_array ( $ schemaKey , $ this -> _columns ) ) { $ sortedColumns [ $ schemaKey ] = $ schemaKey ; } } foreach ( $ this -> _columns as $ column ) { if ( ! isset ( $ sortedColumns [ $ column ] ) ) { $ class_name = get_called_class ( ) ; throw new Exception ( "No type hinting/docblock found for '{$column}' in '{$class_name}'." , E_USER_WARNING ) ; } } $ this -> _columns = array_values ( $ sortedColumns ) ; // Return sorted columns. return $ this -> _columns ; }
Work out which columns should be saved down.
Work out which columns should be saved down .