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;
    }