public function getTableRows($baseName, $tableName, $rowCount = SAMPLE_DATA_LENGTH)
{
if (!$baseName) {
throw new Exception('$baseName is not set');
}
if (!$tableName) {
throw new Exception('$tableName is not set');
}
$rowCount = (int) $rowCount;
$tableName = preg_replace("\$[^A-z0-9.,-_]\$", '', $tableName);
switch (DRIVER) {
case "mssql":
case "dblib":
$query = 'SELECT TOP ' . $rowCount . ' * FROM ' . $baseName . '..' . $tableName;
break;
case "pgsql":
case "mysql":
$query = 'SELECT * FROM ' . $tableName . ' LIMIT ' . $rowCount;
break;
}
if ($baseName === FIRST_BASE_NAME) {
$result = $this->_select($query, $this->_getFirstConnect(), FIRST_BASE_NAME);
} else {
$result = $this->_select($query, $this->_getSecondConnect(), SECOND_BASE_NAME);
}
if ($result) {
$firstRow = array_shift($result);
$out[] = array_keys($firstRow);
$out[] = array_values($firstRow);
foreach ($result as $row) {
$out[] = array_values($row);
}
} else {
$out = array();
}
if (DATABASE_ENCODING != 'utf-8' && $out) {
// $out = array_map(function($item){ return array_map(function($itm){ return iconv(DATABASE_ENCODING, 'utf-8', $itm); }, $item); }, $out);
}
return $out;
}