Re: Re: Datagrid followup
| From: | Wolfram Kriesing | Date: | Fri, 19 Apr 2002 14:46:38 +0000 |
| Subject: | Re: Re: Datagrid followup | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-5679@lists.php.net to get a copy of this message | ||
On Friday 19 April 2002 16:32, you wrote:
> le 19/04/02 15:01, Markus Wolff à wolff@21st.de a écrit :
> > Am Fri, 19 Apr 2002 14:16:15 +0200 schrieb Bertrand Mansion
> >
> > <bmansion@mamasam.com>:
> >> Is there a way, using PEAR DB, to get field type info, like PHPLib used
> >> to do it with Metadata ?
> >>
> >> If so, this could be used to create the right widgets for inputs when in
> >> edit mode.
> >
> > My thought exactly! And yes, there is a possibility:
> > http://pear.php.net/manual/en/core.db.tableinfo.php
> >
> > But unfortunately, this won´t work with InterBase, Informix, mSQL,
> > Oracle8, ODBC and Sybase. While I can mostly live with that, Oracle8 and
> > ODBC not working with this is pretty sad.
> >
> > My compromise would be to make the widget types for all fields
> > self-configurable but preset them with the appropriate types when using
> > a database that makes this information available.
>
> I am coding the oracle tableinfo() method right now.
> I hope it will be finished this evening...
>
> Bertrand Mansion
> Mamasam
from phplib
/**
*
* !!!! query COPIED FROM db_oci8.inc - from PHPLIB !!!!
*
* @access public
* @see
* @version 2001/09
* @author PHPLIB
* @param
* @return
*/
function metadata( $table='' )
{
$full = false;
if( $table=='' )
$table = $this->table;
$count = 0;
$id = 0;
$res = array();
## This is a RIGHT OUTER JOIN: "(+)", if you want to see, what
## this query results try the following:
## $table = new Table; $this->_db = new my_DB_Sql; # you have to make
## # your own class
## $table->show_results($this->_db->query(see query vvvvvv))
##
$res=$this->_db->getAll("SELECT
T.column_name,T.table_name,T.data_type,".
"T.data_length,T.data_precision,T.data_scale,T.nullable,".
"T.char_col_decl_length,I.index_name".
" FROM ALL_TAB_COLUMNS T,ALL_IND_COLUMNS I".
" WHERE T.column_name=I.column_name (+)".
" AND T.table_name=I.table_name (+)".
" AND T.table_name=UPPER('$table') ORDER BY T.column_id");
if( DB::isError( $res ) )
{
#$this->_error->set( $res->getMessage() );
// i think we only need to log here, since this method is never
used
// directly for the user's functionality, which means if it fails
it
// is most probably an appl error
$this->_error->log( $res->getUserInfo() );
return false;
}
$ret = array();
foreach( $res as $key=>$val )
$ret[$val['COLUMN_NAME']] = $val;
return $ret;
} // end of method
--
Wolfram
... translating template engine ....
http://sf.net/projects/simpletpl
... authentication system ....
http://sf.net/projects/auth