本文整理汇总了PHP中DibiConnection::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP DibiConnection::fetch方法的具体用法?PHP DibiConnection::fetch怎么用?PHP DibiConnection::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DibiConnection
的用法示例。
在下文中一共展示了DibiConnection::fetch方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateStructure
/**
* funkce pro aktualizaci struktury
* @param type $relativePath
*/
public function updateStructure($relativePath, $ownerId = 0)
{
if (empty($relativePath)) {
return true;
}
$relativePath = \Nette\Utils\Strings::endsWith($relativePath, "/") ? substr($relativePath, 0, -1) : $relativePath;
$parts = explode("/", $relativePath);
$create = false;
$count = count($parts);
$c = 0;
$parent = 0;
if ($parts && $count > 0) {
foreach ($parts as $part) {
$folder = $this->connection->fetch("SELECT * FROM [:vd:folders] WHERE [name] = %s", $part);
if (!$folder || $create) {
$data = array('parent' => $parent, 'has_child' => $c < $count ? 1 : 0, 'name' => $part, 'nicename' => \Nette\Utils\Strings::webalize($part), 'editor_id' => $ownerId ?: 0);
if (!empty($part)) {
$this->connection->query('INSERT INTO [:vd:folders] ', $data);
$parent = $this->connection->getInsertId();
}
} elseif ($folder) {
$parent = $folder['folder_id'];
}
if (!$folder || !$folder['has_child']) {
$create = true;
}
$c++;
}
}
return $parent;
}
示例2: foreach
$pairs = $res->fetchPairs('id', 'title');
echo "<option value='' class='optionTexts' selected></option>";
foreach ($pairs as $id => $title) {
echo "<option value='{$id}' class='optionTexts'>{$title}</option>";
}
break;
case "selecttesttype":
$language = mysql_real_escape_string(isset($_GET['la']) ? $_GET['la'] : $default_language);
$res = $db->query('SELECT * FROM TestTypes WHERE language="' . $language . '" AND public=1');
$pairs = $res->fetchPairs('id', 'title');
echo "<option value='' class='optionTestTypes' selected></option>";
foreach ($pairs as $id => $title) {
echo "<option value='{$id}' class='optionTestTypes'>{$title}</option>";
}
break;
case "inserttext":
$id = mysql_real_escape_string(isset($_GET['id']) ? $_GET['id'] : '0');
$text = $db->fetchSingle('SELECT text FROM Texts WHERE id="' . $id . '"');
echo $text;
break;
case "gettesttype":
$id = mysql_real_escape_string(isset($_GET['id']) ? $_GET['id'] : '0');
$row = $db->fetch('SELECT * FROM TestTypes WHERE id="' . $id . '" LIMIT 1');
$terms = $row->terms;
$function = $row->function;
$json = array('terms' => $terms, 'functionName' => $function);
header("Content-Type: application/json", true);
echo json_encode($json);
case "":
break;
}
示例3: DibiConnection
<?php
require_once 'vendor/autoload.php';
require_once 'config.php';
use Dibi\Dibi;
$db = new DibiConnection($database_configuration);
$secret = isset($_GET['secret']) ? $_GET['secret'] : '';
if ($minimise_code) {
$minimise = ".min";
} else {
$minimise = "";
}
$row = $db->fetch('SELECT * FROM Tests WHERE secret="' . $secret . '" LIMIT 1');
$language = $row->language;
$textId = (int) $row->text;
$testTypeId = (int) $row->testtype;
$testText = $row->test;
$solution = $row->solution;
$level = $row->level;
$save = (bool) $row->save;
$public = (bool) $row->public;
if (strlen($language) == 2) {
setcookie('language', $language);
$locale = $db->fetchSingle('SELECT locale FROM Languages WHERE code="' . $language . '"');
} else {
$language = $default_language;
if (isset($_COOKIE['language'])) {
$locale = $db->fetchSingle('SELECT locale FROM Languages WHERE code="' . $_COOKIE['language'] . '"');
} else {
setcookie('language', $default_language);
$locale = $db->fetchSingle('SELECT locale FROM Languages WHERE code="' . $default_language . '"');