本文整理汇总了PHP中Errors::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Errors::get方法的具体用法?PHP Errors::get怎么用?PHP Errors::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Errors
的用法示例。
在下文中一共展示了Errors::get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: backup
/**
* Backup
*
* @param string $host
* @param string $name
* @param string $pass
* @param string $db
* @param string $charset
* @param array $tables
* @return mixed
*/
public function backup($host = null, $name = null, $pass = null, $db = '', $charset = null, $tables = array())
{
$connect = $this->_connect($host, $name, $pass, $db, $charset);
if (is_object($connect)) {
$this->_resource = $connect;
} else {
return $connect;
}
$true = $false = '';
if ($tables) {
if ($tables['tables']) {
foreach ($tables['tables'] as $f) {
$q = $this->_resource->query('SHOW CREATE TABLE `' . str_replace('`', '``', $f) . '`;');
if ($q) {
$tmp = $q->fetch_row();
$true .= $tmp[1] . ";\n\n";
} else {
$false .= $this->_resource->error . "\n";
}
}
}
if ($tables['data']) {
foreach ($tables['data'] as $f) {
$q = $this->_resource->query('SELECT * FROM `' . str_replace('`', '``', $f) . '`;');
if ($q) {
if ($q->num_rows) {
$true .= 'INSERT INTO `' . str_replace('`', '``', $f) . '` VALUES';
while ($row = $q->fetch_row()) {
$true .= "\n(";
foreach ($row as $v) {
$true .= $v === null ? 'NULL,' : "'" . str_replace("'", "''", $v) . "',";
}
$true = rtrim($true, ',') . '),';
}
$true = rtrim($true, ',') . ";\n\n";
}
} else {
$false .= $this->_resource->error . "\n";
}
}
}
if ($true) {
$dir = dirname($tables['file']);
if (!Gmanager::getInstance()->is_dir($dir)) {
Gmanager::getInstance()->mkdir($dir);
}
if (!Gmanager::getInstance()->file_put_contents($tables['file'], $true)) {
$false .= Errors::get() . "\n";
}
}
if ($false) {
return Helper_View::message(Language::get('sql_backup_false') . '<pre>' . trim($false) . '</pre>', Helper_View::MESSAGE_ERROR);
} else {
return Helper_View::message(Language::get('sql_backup_true'), Helper_View::MESSAGE_SUCCESS);
}
} else {
$q = $this->_resource->query('SHOW TABLES;');
if ($q) {
while ($row = $q->fetch_row()) {
$true .= '<option value="' . rawurlencode($row[0]) . '">' . htmlspecialchars($row[0], ENT_NOQUOTES) . '</option>';
}
return $true;
}
}
return false;
}
示例2: setEditFile
/**
* setEditFile
*
* @param string $f
* @param string $text
* @return string
*/
public function setEditFile($f = '', $text = '')
{
Registry::set('setEditFile', $f);
$tmp = Config::getTemp() . '/GmanagerArchivers' . GMANAGER_REQUEST_TIME . '.tmp';
$fp = fopen($tmp, 'w');
if (!$fp) {
return Helper_View::message(Language::get('fputs_file_false') . '<br/>' . Errors::get(), Helper_View::MESSAGE_ERROR_EMAIL);
}
fputs($fp, $text);
fclose($fp);
$zip = $this->_open();
$comment = $zip->properties();
$comment = $comment['comment'];
if ($zip->delete(PCLZIP_OPT_BY_NAME, $f) == 0) {
if (Config::get('Gmanager', 'mode') == 'FTP') {
Gmanager::getInstance()->ftpArchiveEnd();
}
unlink($tmp);
return Helper_View::message(Language::get('fputs_file_false') . '<br/>' . $zip->errorInfo(true), Helper_View::MESSAGE_ERROR_EMAIL);
}
function pclzip_pre_add($p_event, &$p_header)
{
$p_header['stored_filename'] = Registry::get('setEditFile');
return 1;
}
$fl = $zip->add($tmp, PCLZIP_CB_PRE_ADD, 'pclzip_pre_add', PCLZIP_OPT_COMMENT, $comment);
unlink($tmp);
if (Config::get('Gmanager', 'mode') == 'FTP') {
Gmanager::getInstance()->ftpArchiveEnd($this->_name);
}
if ($fl) {
return Helper_View::message(Language::get('fputs_file_true'), Helper_View::MESSAGE_SUCCESS);
} else {
return Helper_View::message(Language::get('fputs_file_false'), Helper_View::MESSAGE_ERROR_EMAIL);
}
}
示例3: backup
/**
* Backup
*
* @param string $host (not used)
* @param string $name (not used)
* @param string $pass (not used)
* @param string $db
* @param string $charset (not used)
* @param array $tables
* @return string|bool
*/
public function backup($host = null, $name = null, $pass = null, $db = '', $charset = null, $tables = array())
{
$connect = $this->_connect($db);
if ($connect instanceof PDO) {
$this->_resource = $connect;
} else {
return $connect;
}
$true = $false = '';
if ($tables) {
if ($tables['tables']) {
foreach ($tables['tables'] as $f) {
$q = $this->_resource->query('PRAGMA table_info(`' . str_replace('`', '``', $f) . '`);');
if ($q) {
$true .= 'CREATE TABLE `' . str_replace('`', '``', $f) . '` (' . "\n";
foreach ($q->fetchAll(PDO::FETCH_ASSOC) as $v) {
$true .= ' ' . $v['name'] . ' ' . $v['type'] . ($v['notnull'] ? ' NOT NULL' : '') . ' DEFAULT ' . ($v['dflt_value'] === null || $v['dflt_value'] == 'NULL' ? 'NULL' : '"' . $v['dflt_value'] . '"') . ($v['pk'] ? ' PRIMARY KEY' : '') . ",\n";
}
$true = trim($true, ",\n") . "\n" . ');' . "\n\n";
} else {
$tmp = $this->_resource->errorInfo();
$false .= $tmp[2] . "\n";
}
}
}
if ($tables['data']) {
foreach ($tables['data'] as $f) {
$q = $this->_resource->query('SELECT * FROM `' . str_replace('`', '``', $f) . '`;');
if ($q) {
if ($q->columnCount()) {
$true .= 'INSERT INTO `' . str_replace('`', '``', $f) . '` VALUES';
while ($row = $q->fetch(PDO::FETCH_NUM)) {
$true .= "\n(";
foreach ($row as $v) {
$true .= $v === null ? 'NULL,' : "'" . str_replace("'", "''", $v) . "',";
}
$true = rtrim($true, ',') . '),';
}
$true = rtrim($true, ',') . ";\n\n";
}
} else {
$tmp = $this->_resource->errorInfo();
$false .= $tmp[2] . "\n";
}
}
}
if ($true) {
$dir = dirname($tables['file']);
if (!Gmanager::getInstance()->is_dir($dir)) {
Gmanager::getInstance()->mkdir($dir, null, true);
}
if (!Gmanager::getInstance()->file_put_contents($tables['file'], $true)) {
$false .= Errors::get() . "\n";
}
}
if ($false) {
return Helper_View::message(Language::get('sql_backup_false') . '<pre>' . htmlspecialchars(trim($false), ENT_NOQUOTES) . '</pre>', Helper_View::MESSAGE_ERROR);
} else {
return Helper_View::message(Language::get('sql_backup_true'), Helper_View::MESSAGE_SUCCESS);
}
} else {
$q = $this->_resource->query('SELECT name FROM sqlite_master WHERE type = "table" ORDER BY name;');
if ($q) {
while ($row = $q->fetch(PDO::FETCH_NUM)) {
$true .= '<option value="' . rawurlencode($row[0]) . '">' . htmlspecialchars($row[0], ENT_NOQUOTES) . '</option>';
}
return $true;
}
}
return false;
}
示例4: backup
/**
* Backup
*
* @param string $host
* @param string $name
* @param string $pass
* @param string $db
* @param string $charset
* @param array $tables
* @return string|bool
*/
public function backup($host = null, $name = null, $pass = null, $db = '', $charset = null, $tables = array())
{
$connect = $this->_connect($host, $name, $pass, $db, $charset);
if ($connect instanceof PDO) {
$this->_resource = $connect;
} else {
return $connect;
}
$true = $false = '';
if ($tables) {
if ($tables['tables']) {
foreach ($tables['tables'] as $f) {
$out = array();
exec(escapeshellcmd(Config::get('Postgres', 'path')) . ' -U ' . escapeshellarg($name) . ' -F p -b -s -t ' . escapeshellarg($f) . ' ' . escapeshellarg($db), $out);
if ($out) {
$true .= implode("\n", $out);
} else {
$false .= Language::get('sql_schema_error') . htmlspecialchars($f, ENT_NOQUOTES) . "\n";
}
}
}
if ($tables['data']) {
foreach ($tables['data'] as $f) {
$q = $this->_resource->query('SELECT * FROM ' . str_replace(array('"', "'"), array('""', "''"), $f) . ';');
if ($q) {
if ($q->columnCount()) {
$true .= 'INSERT INTO ' . str_replace(array('"', "'"), array('""', "''"), $f) . ' VALUES';
while ($row = $q->fetch(PDO::FETCH_NUM)) {
$true .= "\n(";
foreach ($row as $v) {
$true .= $v === null ? 'NULL,' : "'" . str_replace("'", "''", $v) . "',";
}
$true = rtrim($true, ',') . '),';
}
$true = rtrim($true, ',') . ";\n\n";
}
} else {
$tmp = $this->_resource->errorInfo();
$false .= $tmp[2] . "\n";
}
}
}
if ($true) {
$dir = dirname($tables['file']);
if (!Gmanager::getInstance()->is_dir($dir)) {
Gmanager::getInstance()->mkdir($dir, null, true);
}
if (!Gmanager::getInstance()->file_put_contents($tables['file'], $true)) {
$false .= Errors::get() . "\n";
}
}
if ($false) {
return Helper_View::message(Language::get('sql_backup_false') . '<pre>' . trim($false) . '</pre>', Helper_View::MESSAGE_ERROR);
} else {
return Helper_View::message(Language::get('sql_backup_true'), Helper_View::MESSAGE_SUCCESS);
}
} else {
$q = $this->_resource->query('SELECT * FROM information_schema.tables;');
if ($q) {
while ($row = $q->fetch(PDO::FETCH_ASSOC)) {
$true .= '<option value="' . rawurlencode($row['table_name']) . '">' . htmlspecialchars($row['table_name'], ENT_NOQUOTES) . '</option>';
}
return $true;
}
}
return false;
}
示例5: fname
/**
* fname
*
* @param string $f
* @param string $name
* @param int $register
* @param int $i
* @param bool $overwrite
* @return string
*/
public function fname($f = '', $name = '', $register = 0, $i = 0, $overwrite = false)
{
// [replace=from,to] - replace
// [n=0] - meter
// [f] - type
// [name] - name
// [date] - date
// [rand=8,16] - random
// $f = rawurldecode($f);
$info = pathinfo($f);
$info['dirname'] = IOWrapper::get($info['dirname']);
$info['basename'] = IOWrapper::get($info['basename']);
$info['extension'] = IOWrapper::get($info['extension']);
$info['filename'] = IOWrapper::get($info['filename']);
if (preg_match_all('/\\[replace=([^,]),([^\\]])/U', $name, $arr, PREG_SET_ORDER)) {
foreach ($arr as $var) {
$name = str_replace($var[1], $var[2], $info['filename'] . '.' . $info['extension']);
}
}
if (preg_match_all('/\\[n=*(\\d*)\\]/U', $name, $arr, PREG_SET_ORDER)) {
foreach ($arr as $var) {
$name = str_replace($var[0], $var[1] + $i, $name);
}
}
if (preg_match_all('/\\[rand=*(\\d*),*(\\d*)\\]/U', $name, $arr, PREG_SET_ORDER)) {
foreach ($arr as $var) {
$name = str_replace($var[0], mb_substr(str_shuffle(Config::get('Gmanager', 'rand')), 0, mt_rand(!empty($var[1]) ? $var[1] : 8, !empty($var[2]) ? $var[2] : 16)), $name);
}
}
$name = str_replace('[f]', $info['extension'], $name);
$name = str_replace('[name]', $info['filename'], $name);
$name = str_replace('[date]', strftime('%d_%m_%Y'), $name);
if ($register == 1) {
$tmp = mb_strtolower($name);
} elseif ($register == 2) {
$tmp = mb_strtoupper($name);
} else {
$tmp = $name;
}
if (!$overwrite && self::$_instance->file_exists($info['dirname'] . '/' . $tmp)) {
return Helper_View::message(Language::get('overwrite_false') . ' (' . htmlspecialchars($info['dirname'] . '/' . $tmp, ENT_NOQUOTES) . ')', Helper_View::MESSAGE_ERROR);
}
if (self::$_instance->rename($f, $info['dirname'] . '/' . $tmp)) {
return Helper_View::message($info['basename'] . ' - ' . $tmp, Helper_View::MESSAGE_SUCCESS);
} else {
return Helper_View::message(Errors::get() . ' ' . $info['basename'] . ' -> ' . $tmp, Helper_View::MESSAGE_ERROR_EMAIL);
}
}