本文整理汇总了PHP中Nette\Database\Connection::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP Connection::fetch方法的具体用法?PHP Connection::fetch怎么用?PHP Connection::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Database\Connection
的用法示例。
在下文中一共展示了Connection::fetch方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setTranslation
public function setTranslation($original, $translated, $lang, $variant = 0, $namespace = NULL)
{
$arg = array();
$arg[0] = "SELECT `id` FROM {$this->defaultTable} WHERE ";
if ($namespace) {
$arg[0] .= '`ns` = ? AND ';
$arg[] = $namespace;
}
$arg[0] .= "BINARY `text` = ?";
$arg[] = $original;
$textId = $this->fetchField($arg);
if ($textId) {
$id = $this->fetchField(array("\n\t\t\t\tSELECT `id` FROM {$this->translationTable}\n\t\t\t\tWHERE `text_id` = ? AND `lang` = ? AND `variant` = ?", $textId, $lang, $variant));
}
if ($textId && $id) {
$this->db->query("UPDATE {$this->translationTable} SET translation = ? WHERE id = ?", $translated, $id);
} else {
if (!$textId) {
$data = array('text' => $original);
if ($namespace) {
$data['ns'] = $namespace;
}
$this->db->query("INSERT INTO {$this->defaultTable} ?", $data);
$textId = $this->db->fetch("SELECT LAST_INSERT_ID() id")->id;
}
$this->db->query("INSERT INTO {$this->translationTable} ?", array('text_id' => $textId, 'lang' => $lang, 'variant' => $variant, 'translation' => $translated));
}
}