src/Budkit/Datastore/Drivers/MySQLi/Table.php
public function describe()
    {

        $sql = 'DESCRIBE ' . $this->name;
        $schema = $this->dbo->prepare($sql)->execute();

        while ($row = $schema->fetchObject()) {

            if (preg_match('/unsigned/', $row->Type)) {
                $row->Unsigned = true;
            }
            if (preg_match('/^((?:var)?char)\((\d+)\)/', $row->Type, $matches)) {
                //$row->Type      = $matches[1];
                $row->Validate = 'string'; //
                $row->Length = $matches[2];
            } else if (preg_match('/^decimal\((\d+),(\d+)\)/', $row->Type, $matches)) {
                //$row->Type      = 'decimal';
                $row->Validate = 'decimal';
                $row->Precission = $matches[1];
                $row->Scale = $matches[2];
            } else if (preg_match('/^float\((\d+),(\d+)\)/', $row->Type, $matches)) {
                //$row->Type      = 'float';
                $row->Validate = 'float';
                $row->Precission = $matches[1];
                $row->Scale = $matches[2];
            } else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', $row->Type, $matches)) {
                //$row->Type = 'interger'; //$matches[1];
                $row->Validate = 'interger';
                $row->Length = $matches[2];
            }
            if (strtoupper($row->Key) == 'PRI') {
                $row->Primary = true;

                if ($row->Extra == 'auto_increment') {
                    $row->Identity = true;
                } else {
                    $row->Identity = false;
                }
            }

            if (strtoupper($row->Null) == 'NO') {
                $row->Null = 0;
            } else {
                $row->Null = 1;
            }

            $this->schema[$row->Field] = $row;
        }

        //Just something good!
        return true;
    }
public function describe()
    {

        $sql = 'DESCRIBE ' . $this->name;
        $schema = $this->dbo->prepare($sql)->execute();

        while ($row = $schema->fetchObject()) {

            if (preg_match('/unsigned/', $row->Type)) {
                $row->Unsigned = true;
            }
            if (preg_match('/^((?:var)?char)\((\d+)\)/', $row->Type, $matches)) {
                //$row->Type      = $matches[1];
                $row->Validate = 'string'; //
                $row->Length = $matches[2];
            } else if (preg_match('/^decimal\((\d+),(\d+)\)/', $row->Type, $matches)) {
                //$row->Type      = 'decimal';
                $row->Validate = 'decimal';
                $row->Precission = $matches[1];
                $row->Scale = $matches[2];
            } else if (preg_match('/^float\((\d+),(\d+)\)/', $row->Type, $matches)) {
                //$row->Type      = 'float';
                $row->Validate = 'float';
                $row->Precission = $matches[1];
                $row->Scale = $matches[2];
            } else if (preg_match('/^((?:big|medium|small|tiny)?int)\((\d+)\)/', $row->Type, $matches)) {
                //$row->Type = 'interger'; //$matches[1];
                $row->Validate = 'interger';
                $row->Length = $matches[2];
            }
            if (strtoupper($row->Key) == 'PRI') {
                $row->Primary = true;

                if ($row->Extra == 'auto_increment') {
                    $row->Identity = true;
                } else {
                    $row->Identity = false;
                }
            }

            if (strtoupper($row->Null) == 'NO') {
                $row->Null = 0;
            } else {
                $row->Null = 1;
            }

            $this->schema[$row->Field] = $row;
        }

        //Just something good!
        return true;
    }
public function describe ( ) { $ sql = 'DESCRIBE ' . $ this -> name ; $ schema = $ this -> dbo -> prepare ( $ sql ) -> execute ( ) ; while ( $ row = $ schema -> fetchObject ( ) ) { if ( preg_match ( '/unsigned/' , $ row -> Type ) ) { $ row -> Unsigned = true ; } if ( preg_match ( '/^((?:var)?char)\((\d+)\)/' , $ row -> Type , $ matches ) ) { //$row->Type      = $matches[1]; $ row -> Validate = 'string' ; // $ row -> Length = $ matches [ 2 ] ; } else if ( preg_match ( '/^decimal\((\d+),(\d+)\)/' , $ row -> Type , $ matches ) ) { //$row->Type      = 'decimal'; $ row -> Validate = 'decimal' ; $ row -> Precission = $ matches [ 1 ] ; $ row -> Scale = $ matches [ 2 ] ; } else if ( preg_match ( '/^float\((\d+),(\d+)\)/' , $ row -> Type , $ matches ) ) { //$row->Type      = 'float'; $ row -> Validate = 'float' ; $ row -> Precission = $ matches [ 1 ] ; $ row -> Scale = $ matches [ 2 ] ; } else if ( preg_match ( '/^((?:big|medium|small|tiny)?int)\((\d+)\)/' , $ row -> Type , $ matches ) ) { //$row->Type = 'interger'; //$matches[1]; $ row -> Validate = 'interger' ; $ row -> Length = $ matches [ 2 ] ; } if ( strtoupper ( $ row -> Key ) == 'PRI' ) { $ row -> Primary = true ; if ( $ row -> Extra == 'auto_increment' ) { $ row -> Identity = true ; } else { $ row -> Identity = false ; } } if ( strtoupper ( $ row -> Null ) == 'NO' ) { $ row -> Null = 0 ; } else { $ row -> Null = 1 ; } $ this -> schema [ $ row -> Field ] = $ row ; } //Just something good! return true ; }
Describes a table on load
Describes a table on load