src/Budkit/Datastore/Drivers/MySQLi/Table.php
public function keys($type = 'primary', $limit = 1)
    {

        $valid = array("primary" => 'PRI', "unique" => 'UNI', "multiple" => 'MUL');

        //Check if we have a valid key Type;
        if (empty($this->schema) || !array_key_exists($type, $valid)) {
            return array();
        }

        $keys = array();
        $i = 0;

        foreach ($this->schema as $field => $schema) {

            if ($limit > 0 && $i >= $limit)
                break; //useful with compound keys

            if (strval($schema->Key) == $valid[$type]) {
                $keys[$field] = $schema;
            }
            $i++;
        }

        $return = (array)$keys;

        if ($limit === 1 && !empty($return)) {
            $fieldname = array_keys($return);
            $return = $return[$fieldname[0]];
        }
        return $return;
    }
public function keys($type = 'primary', $limit = 1)
    {

        $valid = array("primary" => 'PRI', "unique" => 'UNI', "multiple" => 'MUL');

        //Check if we have a valid key Type;
        if (empty($this->schema) || !array_key_exists($type, $valid)) {
            return array();
        }

        $keys = array();
        $i = 0;

        foreach ($this->schema as $field => $schema) {

            if ($limit > 0 && $i >= $limit)
                break; //useful with compound keys

            if (strval($schema->Key) == $valid[$type]) {
                $keys[$field] = $schema;
            }
            $i++;
        }

        $return = (array)$keys;

        if ($limit === 1 && !empty($return)) {
            $fieldname = array_keys($return);
            $return = $return[$fieldname[0]];
        }
        return $return;
    }
public function keys ( $ type = 'primary' , $ limit = 1 ) { $ valid = array ( "primary" => 'PRI' , "unique" => 'UNI' , "multiple" => 'MUL' ) ; //Check if we have a valid key Type; if ( empty ( $ this -> schema ) || ! array_key_exists ( $ type , $ valid ) ) { return array ( ) ; } $ keys = array ( ) ; $ i = 0 ; foreach ( $ this -> schema as $ field => $ schema ) { if ( $ limit > 0 && $ i >= $ limit ) break ; //useful with compound keys if ( strval ( $ schema -> Key ) == $ valid [ $ type ] ) { $ keys [ $ field ] = $ schema ; } $ i ++ ; } $ return = ( array ) $ keys ; if ( $ limit === 1 && ! empty ( $ return ) ) { $ fieldname = array_keys ( $ return ) ; $ return = $ return [ $ fieldname [ 0 ] ] ; } return $ return ; }
Returns all fields corresponding to the key type

@param string $type primary, unique, multiple
Returns all fields corresponding to the key type