Odkazy: dibi | API reference

Forum: [česky] [english]

dibi fórum

tiny ‘n’ smart
database layer

Nejste přihlášen(a)

#1 před 2 lety

lucien144
Nový člen
Registrovaný: 11. 6. 2006
Příspěvky: 2

getIndexes a fulltext

Vsiml jsem si, ze MySQL driver nevraci v metode getIndexes informaci o tom, zda je klic typu FULLTEXT ci ne. Upravil jsem si tedy lehce driver a pridal navic metodu, ktera vrati v poli primo sloupce, ktere jsou typu FULLTEXT. Snad se to nekomu bude hodit…

<?php

require_once( dirname(__FILE__) . '/mysql.php' );

class DibiMy_MySQLDriver extends DibiMySqlDriver {

        public function getIndexes($table)
        {
                $this->query("SHOW INDEX FROM `$table`");
                $res = array();
                while ($row = $this->fetch(TRUE)) {
                        $res[$row['Key_name']]['name']          = $row['Key_name'];
                        $res[$row['Key_name']]['fulltext']      = $row['Index_type'] == 'FULLTEXT' ? TRUE : FALSE;
                        $res[$row['Key_name']]['unique']        = !$row['Non_unique'];
                        $res[$row['Key_name']]['primary']       = $row['Key_name'] === 'PRIMARY';
                        $res[$row['Key_name']]['columns'][$row['Seq_in_index'] - 1] = $row['Column_name'];
                        $res[$row['Key_name']]['columns'][$row['Seq_in_index'] - 1] = $row['Column_name'];
                }
                $this->free();
                return array_values($res);
        }

        public function getFulltexts($table)
        {
                $this->query("SHOW INDEX FROM `$table` WHERE `Index_type` = 'FULLTEXT'");
                $res = array();
                while ($row = $this->fetch(TRUE)) {

                        $res[$row['Key_name']][$row['Seq_in_index'] - 1] = $row['Column_name'];

                }
                $this->free();
                return $res;
        }

}
/** End of file: mysql_extended.php */

?>

 

Zápatí