/** * getStructure * * @param mixed $table Description. * @param mixed $io Description. * * @access public * * @return mixed Value. */ public function getStructure($table = null, $io = true) { if (gettype($table) === 'NULL') { exit('No table defined'); } $bdd = self::dbConnect(); if (self::tableExists($table)) { $response = $bdd->prepare("DESCRIBE {$table}"); $response->execute(); while ($row = $response->fetch(PDO::FETCH_ASSOC)) { $total = Extras::pluralize('column', count($row)); $rows[] = $row; $fields[] = $row['Field']; } if ($io) { print "There is <b>{$total}</b> in <b>{$table}</b> table.<br />"; // print_r($fields); print implode("<br>", array_map(function ($str, $row) { return Extras::wrapper($str, 'input', array(), true) . $row['Type']; }, $fields, $rows)); } return $fields; } else { exit("Table `{$table}` doesn't exist"); } }