本文整理匯總了PHP中DibiConnection::translate方法的典型用法代碼示例。如果您正苦於以下問題:PHP DibiConnection::translate方法的具體用法?PHP DibiConnection::translate怎麽用?PHP DibiConnection::translate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DibiConnection
的用法示例。
在下文中一共展示了DibiConnection::translate方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __toString
/**
* Returns SQL query.
* @return string
*/
public final function __toString()
{
try {
return $this->connection->translate($this->_export());
} catch (Exception $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
}
}
示例2: __toString
/**
* Returns SQL query.
* @return string
*/
public function __toString()
{
return $this->connection->translate('
SELECT %n', empty($this->cols) ? '*' : $this->cols, '
FROM %SQL', $this->sql, '
%ex', $this->conds ? array('WHERE %and', $this->conds) : NULL, '
%ex', $this->sorting ? array('ORDER BY %by', $this->sorting) : NULL, '
%ofs %lmt', $this->offset, $this->limit);
}
示例3: __toString
/**
* Returns SQL query.
* @return string
*/
public function __toString()
{
try {
return $this->connection->translate('
SELECT %n', empty($this->cols) ? '*' : $this->cols, '
FROM %SQL', $this->sql, '
%ex', $this->conds ? array('WHERE %and', $this->conds) : NULL, '
%ex', $this->sorting ? array('ORDER BY %by', $this->sorting) : NULL, '
%ofs %lmt', $this->offset, $this->limit);
} catch (Exception $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
}
}
示例4: dumpData
/**
* @param DibiConnection
* @param string table name
* @param string file path
*
* @return int
* @throws DibiException
* @throws Nette\IOException
*/
function dumpData(DibiConnection $db, $table, $file)
{
$rows = $db->query("SELECT * FROM %n", $table)->fetchAll();
if (count($rows) == 0) {
if (file_exists($file) && !unlink($file)) {
throw new Nette\IOException("Failed to delete {$file}");
}
return;
}
$sql = "" . "--\n" . "-- Data for table: {$table}\n" . "-- Generated: " . date("Y-m-d H:i:s") . "\n" . "--\n" . "START TRANSACTION;\n";
$perCommand = 10;
for ($i = 0; $i < ceil(count($rows) / $perCommand); $i++) {
$slice = array_slice($rows, $i * $perCommand, $perCommand);
$sql .= $db->translate("INSERT INTO %n %ex", $table, $slice) . ";\n";
}
$sql .= "COMMIT;\n";
if (file_put_contents($file, $sql) === FALSE) {
throw new Nette\IOException("Cannot write to file '{$file}'");
}
}
示例5: __toString
/**
* Returns SQL query.
* @return string
*/
public final function __toString()
{
return $this->connection->translate($this->_export());
}