API16

Difference between revisions of "JDatabaseMySQLi/getTableFields"

From Joomla! Documentation

< API16:JDatabaseMySQLi
(New page: ===Description=== Retrieves information about the given tables <span class="editsection" style="font-size:76%;"> <nowiki>[</nowiki>[[Description:JDatabaseMySQLi/getTableFields|Edit De...)
 
m (preparing for archive only)
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
Retrieves information about the given tables
 
Retrieves information about the given tables
  
<span class="editsection" style="font-size:76%;">
 
<nowiki>[</nowiki>[[Description:JDatabaseMySQLi/getTableFields|Edit Descripton]]<nowiki>]</nowiki>
 
</span>
 
  
{{Description:JDatabaseMySQLi/getTableFields}}
+
 
 +
<! removed transcluded page call, red link never existed >
  
 
===Syntax===
 
===Syntax===
Line 60: Line 58:
 
</source>
 
</source>
  
<span class="editsection" style="font-size:76%;">
+
 
<nowiki>[</nowiki>[[SeeAlso:JDatabaseMySQLi/getTableFields|Edit See Also]]<nowiki>]</nowiki>
+
<! removed transcluded page call, red link never existed >
</span>
 
{{SeeAlso:JDatabaseMySQLi/getTableFields}}
 
  
 
===Examples===
 
===Examples===
<CodeExamplesForm />
+
=== Code Examples ===
 
<dpl>
 
<dpl>
 
  noresultsheader=\n
 
  noresultsheader=\n
 
  category=getTableFields
 
  category=getTableFields
 
  category=JDatabaseMySQLi
 
  category=JDatabaseMySQLi
  category=CodeExample
+
  namespace=CodeExample
 
  category=MethodExample
 
  category=MethodExample
 
  include=*
 
  include=*
 
  format= ,,,
 
  format= ,,,
 
</dpl>
 
</dpl>
 +
[[Category:Archived pages API16]]

Latest revision as of 20:28, 24 March 2017

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

Retrieves information about the given tables


<! removed transcluded page call, red link never existed >

Syntax[edit]

getTableFields($tables, $typeonly=true)
Parameter Name Default Value Description
$tables A table name or a list of table names
$typeonly true Only return field types, default true

Returns[edit]

array An array of fields by table

Defined in[edit]

libraries/joomla/database/database/mysqli.php

Importing[edit]

jimport( 'joomla.database.database.mysqli' );

Source Body[edit]

public function getTableFields($tables, $typeonly = true)
{
        settype($tables, 'array'); //force to array
        $result = array();

        foreach ($tables as $tblval) {
                $this->setQuery('SHOW FIELDS FROM ' . $tblval);
                $fields = $this->loadObjectList();

                if ($typeonly) {
                        foreach ($fields as $field) {
                                $result[$tblval][$field->Field] = preg_replace("/[(0-9)]/",'', $field->Type);
                        }
                } else {
                        foreach ($fields as $field) {
                                $result[$tblval][$field->Field] = $field;
                        }
                }
        }

        return $result;
}


<! removed transcluded page call, red link never existed >

Examples[edit]

Code Examples[edit]