本文整理汇总了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());
}