Exemplo n.º 1
0
<?php

require_once 'DB.php';
require_once 'Console/Table.php';
$dbh = DB::connect('mysqli://*****:*****@localhost/pear');
if (PEAR::isError($dbh)) {
    die('Database connection failed');
}
$sql = '
SELECT p.name, p.license
FROM packages p
WHERE p.package_type = "pear" AND p.license LIKE "%PHP%"
ORDER BY p.name';
$data = $dbh->getAll($sql, DB_FETCHMODE_ASSOC);
$table = new Console_Table();
$table->setHeaders(array('Package (' . count($data) . ')', 'License'));
$table->addData($data);
echo $table->getTable();
Exemplo n.º 2
0
 /**
  * Return pretty printed table from data, useful for printing to console or wrapped in <pre>
  * @return string
  */
 public function getValue()
 {
     require_once 'Console/Table.php';
     $tbl = new \Console_Table();
     $tbl->setHeaders($this->getColHeadings());
     $tbl->addData($this->getAllRows());
     return $tbl->getTable();
 }