本文整理汇总了PHP中SQL::fetchsingle方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::fetchsingle方法的具体用法?PHP SQL::fetchsingle怎么用?PHP SQL::fetchsingle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL::fetchsingle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: COUNT
function get_subgroups_count()
{
$sql = $this->site->db->prepare("SELECT COUNT(*) FROM groups WHERE parent_group_id=?", $this->group_id);
$sth = new SQL($sql);
$subgroups_count = $sth->fetchsingle();
return $subgroups_count;
}
示例2: __construct
public function __construct()
{
$sql = "SELECT description FROM version WHERE version_nr = '4.7.FINAL'";
$result = new SQL($sql);
$this->lastUpdate = (int) $result->fetchsingle();
if (!$this->lastUpdate) {
$this->lastUpdate = 479;
}
$this->cli = php_sapi_name() == 'cli' ? true : false;
$this->ln = $this->cli == 'cli' ? "\n" : '<br>';
}
示例3: smarty_function_save_mailinglist
/**
* This source file is is part of Saurus CMS content management software.
* It is licensed under MPL 1.1 (http://www.opensource.org/licenses/mozilla1.1.php).
* Copyright (C) 2000-2010 Saurused Ltd (http://www.saurus.info/).
* Redistribution of this file must retain the above copyright notice.
*
* Please note that the original authors never thought this would turn out
* such a great piece of software when the work started using Perl in year 2000.
* Due to organic growth, you may find parts of the software being
* a bit (well maybe more than a bit) old fashioned and here's where you can help.
* Good luck and keep your open source minds open!
*
* @package SaurusCMS
* @copyright 2000-2010 Saurused Ltd (http://www.saurus.info/)
* @license Mozilla Public License 1.1 (http://www.opensource.org/licenses/mozilla1.1.php)
*
*/
function smarty_function_save_mailinglist($params, &$smarty)
{
global $site;
extract($params);
$user_id = (int) $user;
if (!$user_id) {
$user_id = $site->user->user_id;
}
###################
# salvestame mailinglistide valik
# muide, kui kasutaja e-mail salvestati tühjana, siis ei lisata ka ühtegi meili-listi ja kustutatakse vanadki
if ($user_id) {
// get user data
$sql = $site->db->prepare('select * from users where user_id = ?', $user_id);
$result = new SQL($sql);
$user_data = $result->fetch('ASSOC');
###################
# salvestame mailinglistide valik
# ja lisada uued mailinglistid
###################
# kustutada vanad mailinglistid
$sql = $site->db->prepare("SELECT user_mailinglist.objekt_id FROM user_mailinglist LEFT JOIN objekt ON user_mailinglist.objekt_id = objekt.objekt_id WHERE user_mailinglist.user_id = ? AND objekt.keel=?", $user_id, $site->keel);
$sth = new SQL($sql);
$site->debug->msg($sth->debug->get_msgs());
$del_obj = array();
while ($del_obj_id = $sth->fetchsingle()) {
$del_obj[] = $del_obj_id;
}
$sql = $site->db->prepare("DELETE FROM user_mailinglist WHERE user_id=? AND FIND_IN_SET(objekt_id,?)", $user_id, join(",", $del_obj));
$sth = new SQL($sql);
$site->debug->msg($sth->debug->get_msgs());
# ja lisada uued (NB! aga ainult siis kui kasutaja e-mail ei ole tühi)
if (trim($site->user->all['email'] != '') && is_array($fields)) {
# rubrigide ID kontroll
# kas on seal meilinglist, kas on rubriik avaldatud
$sql = $site->db->prepare("SELECT obj_rubriik.objekt_id FROM obj_rubriik,objekt WHERE obj_rubriik.objekt_id=objekt.objekt_id AND objekt.on_avaldatud='1' AND obj_rubriik.on_meilinglist = '1' AND find_in_set(obj_rubriik.objekt_id, ?)", join(",", $fields));
$sth = new SQL($sql);
$site->debug->msg($sth->debug->get_msgs());
$values = array();
while ($objekt_id = $sth->fetchsingle()) {
$values[] = $site->db->prepare("(?,?)", $user_id, $objekt_id);
}
if (sizeof($values)) {
$sql = "INSERT INTO user_mailinglist (user_id, objekt_id) VALUES " . join(",", $values);
$sth = new SQL($sql);
$site->debug->msg($sth->debug->get_msgs());
}
}
# if mõni meilinglist oli chekitud
}
# kui kasutaja lisati edukalt
# / salvestame mailinglistide valik
###################
}
示例4: smarty_function_sync_folder
function smarty_function_sync_folder($params, &$smarty)
{
global $site, $leht, $class_path;
##############
# default values
extract($params);
//if(!isset($name)) { $name = 'folder'; }
//eelista id'd
if (isset($id)) {
$id = (int) $id;
$objekt = new Objekt(array('objekt_id' => $id));
//printr($objekt->all);
//kui on album
if ($objekt->all['tyyp_id'] == 16) {
$conf = new CONFIG($objekt->all['ttyyp_params']);
if ($folder_path = $conf->get('path')) {
$folder_path = preg_replace('#^/#', '', $folder_path);
$folder_path = preg_replace('#/$#', '', $folder_path);
$folder_abs_path = $site->absolute_path . $folder_path;
$sql = $site->db->prepare('select objekt_id from obj_folder where relative_path = ?', '/' . $folder_path);
$result = new SQL($sql);
if ($result->rows) {
$id = $result->fetchsingle();
include_once $class_path . 'picture.inc.php';
generate_images($folder_abs_path, $conf->get('tn_size'), $conf->get('pic_size'));
} else {
//no such folder
return;
}
} else {
//no image folder set
return;
}
} elseif ($objekt->all['tyyp_id'] != 22) {
return;
}
} elseif (isset($path)) {
$path = (string) $path;
$path = preg_replace('#^/#', '', $path);
$path = preg_replace('#/$#', '', $path);
$sql = $site->db->prepare('select objekt_id from obj_folder where relative_path = ?', $path);
$result = new SQL($sql);
if ($result->rows) {
$id = $result->fetchsingle();
} else {
//no such folder
return;
}
}
include_once $class_path . 'adminpage.inc.php';
synchronise_folder($id);
}
示例5: rep_id
function rep_id($vana_id, $sitename)
{
global $site;
if (!$vana_id || !$sitename) {
return 0;
}
if ($site->CONF['hostname'] == $sitename) {
return $vana_id;
} else {
$sql = $site->db->prepare("\n\t\t\tSELECT objekt_id FROM objekt WHERE related_objekt_id = ?", $vana_id);
$sth = new SQL($sql);
$id = $sth->fetchsingle();
$site->debug->msg($sth->debug->get_msgs());
return $sth->rows ? $id : $vana_id;
}
}
示例6: array
function get_obj_all_parents($objekt_id = '')
{
# ---------------------------------------
# objekti k�igi parentite v�ljastamine massiivi
# ---------------------------------------
$parents = array();
if (!is_numeric($objekt_id)) {
$objekt_id = $this->objekt_id;
}
if ($objekt_id) {
$sql = $this->site->db->prepare("\n\t\t\t\tSELECT objekt_objekt.parent_id\n\t\t\t\tFROM objekt_objekt \n\t\t\t\tWHERE objekt_objekt.objekt_id=?", $objekt_id);
$sth = new SQL($sql);
while ($par = $sth->fetchsingle()) {
$parents[] = $par;
}
return $parents;
}
}
示例7: SQL
window.opener.location = window.opener.location;
window.close();
//--></SCRIPT>
<?
}
if ($site->fdat['op2'] == 'deleteconfirmed') {
/*-------------------------------------
//Valime kasutaja_id kelle oma see kommentaar on
--------------------------------------*/
$sql = $site->db->prepare("SELECT kasutaja_id FROM obj_kommentaar WHERE objekt_id = ?",$site->fdat[id]);
$sth = new SQL($sql);
$site->debug->msg($sth->debug->get_msgs());
$kommenteerija_id = $sth->fetchsingle();
$curr_obj = new Objekt(array(
objekt_id => $site->fdat['id'],
));
$parent_obj = new Objekt(array(
objekt_id => $curr_obj->parent_id,
));
# $alamlist_count - kui palju üldse kommentaare on, parent jaoks
$alamlist_count = new Alamlist(array(
parent => $curr_obj->parent_id,
klass => "kommentaar",
asukoht => 0,
示例8: SQL
$faulty_obj_arr[$rec['objekt_id']] = $sisu_strip;
}
} # while rec
####### 2) comments/messages
$sql = "SELECT objekt_id, text FROM obj_kommentaar";
$sth = new SQL ($sql);
while($rec = $sth->fetch()){
# strip HTML tags from lyhi, sisu for strip-fields
$sisu_strip = $rec['text'];
$sisu_strip = convert_sisu_strip($sisu_strip);
##### check if fields match
$sql2 = $site->db->prepare("SELECT sisu_strip FROM objekt WHERE objekt_id= ?", $rec['objekt_id']);
$sth2 = new SQL ($sql2);
$sisu_strip_in_db = $sth2->fetchsingle();
if(trim($sisu_strip_in_db) != trim($sisu_strip) ){
$faulty_obj_arr[$rec['objekt_id']] = $sisu_strip;
}
} # while rec
##################
# sql
if (!$site->fdat['run']){
echo "
<tr>
<td><b>object search: Faulty strip-fields</b><br></td>
</tr>
";
}
示例9: import_dict_from_file
/**
* import into CMS dictionary from a CSV text file, returns true on success, false if failes
*
* @param string $cvs_file
* @param boolean $overwrite_user_translations default false
* @param boolean $delete_old_data default false
* @param boolean $write_log default true
* @return boolean
*/
function import_dict_from_file($cvs_file, $overwrite_user_translations = false, $delete_old_data = false, $write_log = true)
{
global $site;
//printr($overwrite_user_translations);
//printr($delete_old_data);
if ($filep = @fopen($cvs_file, 'r')) {
// read file contents into a string
$cvs_file = fread($filep, filesize($cvs_file));
// chop the strings into lines
$cvs_file = str_replace("\r\n", "\n", $cvs_file);
// bug #2397, change the windows linebreaks
$cvs_file = explode("\n", $cvs_file);
$cvs_checksum = null;
$cvs_date = null;
$cvs_encoding = null;
$sys_words = array();
$k = null;
/*
create an array($sys_words) of translation
*/
// for each line in the file
foreach ($cvs_file as $i => $cvs_line) {
//lines with starting with [
if ($cvs_line[0] == '[') {
//chekcsum
if (ereg('^\\[CHECKSUM', $cvs_line)) {
$cvs_checksum = str_replace(array('[CHECKSUM=', ']'), '', $cvs_line);
$cvs_checksum = explode(':', $cvs_checksum);
$cvs_checksum['lang_id'] =& $cvs_checksum[0];
$cvs_checksum['types'] =& $cvs_checksum[1];
$cvs_checksum['words'] =& $cvs_checksum[2];
unset($cvs_file[$i]);
} elseif (ereg('^\\[DATE', $cvs_line)) {
$cvs_date = str_replace(array('[DATE=', ']'), '', $cvs_line);
unset($cvs_file[$i]);
} elseif (ereg('^\\[ENCODING', $cvs_line)) {
$cvs_encoding = trim(str_replace(array('[ENCODING=', ']'), '', $cvs_line));
unset($cvs_file[$i]);
} else {
$k = array_push($sys_words, explode(':', str_replace(array('[', ']'), '', $cvs_line)));
$k--;
$sys_words[$k]['key'] =& $sys_words[$k][0];
$sys_words[$k]['sst_id'] =& $sys_words[$k][1];
$sys_words[$k]['name'] =& $sys_words[$k][2];
}
} elseif ($cvs_line[0] == '#') {
unset($cvs_file[$i]);
} elseif (empty($cvs_line)) {
unset($cvs_file[$i]);
} elseif ($k !== null) {
$cvs_line = explode(';', $cvs_line);
$sys_words[$k]['words'][] = array('sys_word' => $cvs_line[0], 'description' => $cvs_line[1], 'translation' => $cvs_line[2]);
}
}
## check if CHECKSUM line was successfully detected, if not, return error and stop (Bug #2566)
if (trim($cvs_checksum['lang_id']) == '') {
new Log(array('action' => 'import', 'component' => 'Languages', 'type' => 'ERROR', 'message' => 'Dictionary import: invalid language file - CHECKSUM line not detected!'));
return false;
}
/*
// check if the dict file is the same encoding as the language
// no longer neccesssary, because langaugaes and glossaries are different things
$sql = $site->db->prepare('select nimi, encoding from keel where keel_id = ?;', $cvs_checksum['lang_id']);
$result = new SQL($sql);
$result = $result->fetch('ASSOC');
$lang_name = $result['nimi'];
if($write_log && $result['encoding'] != $cvs_encoding)
{
new Log(array(
'action' => 'import',
'component' => 'Languages',
'type' => 'ERROR',
'message' => 'Dictionary import: CSV file encoding does not match language encoding. CSV = "'.$cvs_encoding.'" '.$lang_name.' = "'.$result['encoding'].'".',
));
return false;
}
*/
// update glossary encoding from the language file
$sql = $site->db->prepare("update keel set encoding = ? where keel_id = ?", $cvs_encoding, $cvs_checksum['lang_id']);
$result = new SQL($sql);
if ($result->error) {
new Log(array('action' => 'import', 'component' => 'Languages', 'type' => 'ERROR', 'message' => 'Dictionary import: Could not update glossary encoding. CSV = "' . $cvs_encoding . '" ' . $lang_name . '.'));
return false;
}
//printr($sys_words);
//printr($cvs_checksum);
foreach ($sys_words as $sys_word) {
$sql = $site->db->prepare('select sst_id from sys_sona_tyyp where voti = ?', $sys_word['key']);
$result = new SQL($sql);
$sys_word['sst_id'] = $result->fetchsingle();
if ($result->rows == 0) {
//.........这里部分代码省略.........
示例10: COUNT
<input type=hidden name=op value="<?=$site->fdat['op']?>">
<input type=hidden name=op2 value="">
<table border="0" cellpadding="0" cellspacing="0" style="width:100%; height:100px">
<tr>
<td valign="top" width="100%" class="scms_confirm_delete_cell" height="100%">
<?
# check if allowed to delete
# 1. if exists any data row with that form, then don't allow to delete
$data_count = 0;
############ form content data
$sql = $site->db->prepare("SELECT COUNT(*) FROM ".$form_def['source_table']." WHERE form_id=? ",$form_def['form_id']);
$sth = new SQL($sql);
$form_count = $sth->fetchsingle();
$data_count += $form_count;
if($data_count > 0) {
# show error message
echo "<font color=red>".$site->sys_sona(array(sona => "Permission denied", tyyp=>"editor"))."</font><br><br>";
echo $site->sys_sona(array(sona => "Children count", tyyp=>"admin")).": <b>".$data_count."</b>";
}
# show confirmation
else {
echo $site->sys_sona(array(sona => "kustuta", tyyp=>"editor"))." \"<b>".$form_def['name']."</b>\"? ";
echo $site->sys_sona(array(sona => "are you sure?", tyyp=>"admin"));
$allow_delete = 1;
}
?>
</td>
示例11: SQL
?>
</td>
</tr>
<!-- / forms group -->
<!-- extrenal tabels group -->
<tr height=100%>
<td valign=top>
<?php
########### EXTERNAL TABLES TREES
$sql = $site->db->prepare("show tables");
$sth = new SQL($sql);
while ($tbl_data = $sth->fetchsingle()) {
$tables[] = $tbl_data;
}
#printr($tables);
$ext_tables = array();
foreach ($tables as $table) {
# add table name to array if this has right external prefix
if (substr($table, 0, 4) == 'ext_') {
$ext_tables[] = $table;
}
# if correct prefix
}
##### loop over external tables
foreach ($ext_tables as $ext_table) {
############ PRINT TREE
$sql = $site->db->prepare("SELECT profile_id AS id, source_table AS parent, name FROM object_profiles WHERE source_table=? ORDER BY name", $ext_table);
示例12: print_kast
function print_kast($kast, $is_custom = 0, $archive_link_on = 1)
{
#Muutujad mis hoiab custom stringid
$custom_buttons = '';
$custom_title = '';
$custom_contents = '';
if (get_class($kast) == "Objekt" || is_subclass_of($kast, "Objekt")) {
# ----------------------------
# Uudiste kogumik
# ----------------------------
if ($kast->all[klass] == "kogumik") {
$kast->load_sisu();
if (!$is_custom) {
?>
<table width="<?php
echo $kast->site->dbstyle("menyy_laius", "layout");
?>
" border="0" cellspacing="0" cellpadding="1">
<tr>
<td width="<?php
echo $kast->site->dbstyle("menyy_laius", "layout");
?>
" class="boxhead" height="24">
<?php
echo $kast->pealkiri();
$kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17"));
?>
</td>
</tr>
<tr>
<td width="<?php
echo $kast->site->dbstyle("menyy_laius", "layout");
?>
" bgcolor="<?php
echo $kast->site->dbstyle("menyy_border", "color") ? $kast->site->dbstyle("menyy_border", "color") : "#CCCCCC";
?>
">
<table width="100%" border="0" cellspacing="0" cellpadding="0" bgcolor="<?php
echo $kast->site->dbstyle("menyy_taust", "color") ? $kast->site->dbstyle("menyy_taust", "color") : "#FAFAFA";
?>
">
<tr>
<td align="right" valign="top"><img src="<?php
echo $kast->site->img_path;
?>
/px.gif" width="20" height="10"></td>
<td><img src="<?php
echo $kast->site->img_path;
?>
/px.gif" width="<?php
echo $kast->site->dbstyle("menyy_laius", "layout") - 42;
?>
" height="10"></td>
<td><img src="<?php
echo $kast->site->img_path;
?>
/px.gif" width="20" height="10"></td>
</tr>
<?php
} else {
//Custom print out
ob_start();
$kast->edit_buttons(array(tyyp_idlist => "8,2,6,9,13,17"));
$custom_buttons .= ob_get_contents();
ob_end_clean();
$custom_title .= $kast->pealkiri();
$custom_contents .= "<ul class=\"boxlist\">";
}
//if is_custom
# rubriigid kus uudised otsida
$sql = "SELECT objekt.objekt_id FROM objekt LEFT JOIN objekt_objekt ON objekt_objekt.objekt_id=objekt.objekt_id WHERE objekt_objekt.parent_id=" . $kast->objekt_id . " AND (objekt.kesk = 0 or objekt.kesk = 5 or objekt.kesk = 9) AND objekt.tyyp_id=1";
####### POOLELI
if (!$kast->site->in_editor) {
$sql .= " AND objekt.on_avaldatud=1";
}
if (!$kast->site->in_editor) {
$sql .= " AND !FIND_IN_SET(objekt.objekt_id, '" . join(",", $kast->site->noaccess_hash) . "')";
}
$sth = new SQL($sql);
while ($rid = $sth->fetchsingle()) {
$news_rubrics .= "," . $rid;
}
$kast->debug->msg($sth->debug->get_msgs());
$kast->debug->msg("Rubriigid: {$news_rubrics}");
$sql = "\r\n\t\t\t\t\t\t\tSELECT objekt.objekt_id, objekt.pealkiri, objekt.aeg, objekt.on_avaldatud, objekt_objekt.parent_id \r\n\t\t\t\t\t\t\tFROM objekt \r\n\t\t\t\t\t\t\tLEFT JOIN objekt_objekt ON objekt_objekt.objekt_id=objekt.objekt_id \r\n\t\t\t\t\t\t\tWHERE find_in_set(objekt_objekt.parent_id,'{$news_rubrics}') AND (objekt.kesk=0 OR objekt.kesk=6) AND (objekt.tyyp_id=2 OR objekt.tyyp_id=15)";
if (!$kast->site->in_editor) {
$sql .= " AND objekt.on_avaldatud=1 ";
}
$sql .= " ORDER BY objekt.aeg DESC, objekt_objekt.sorteering DESC limit 0," . ($kast->all[art_arv] ? $kast->all[art_arv] : 5);
$kast->debug->msg($sth->debug->get_msgs());
$sth = new SQL($sql);
$kast->debug->msg("Leitud " . $sth->rows . " alamobjekte");
$esimene = 1;
while ($ary = $sth->fetch()) {
$kast->debug->msg("Objekt leitud: {$ary['objekt_id']}. " . $ary[pealkiri]);
$obj = new Objekt(array(ary => $ary));
if (!$is_custom) {
if (!$esimene) {
# eraldaja
?>
//.........这里部分代码省略.........
示例13: time
$sql = $site->db->prepare("UPDATE objekt SET on_avaldatud=?, last_modified=? WHERE objekt_id=?", 1, time(), $site->fdat['id']);
$sth = new SQL($sql);
$site->debug->msg($sth->debug->get_msgs());
}
#####################
# insert into objekt:
$sql = $site->db->prepare("INSERT INTO objekt (pealkiri, tyyp_id, on_avaldatud, keel, kesk, pealkiri_strip, sisu_strip, aeg, check_in, last_modified, created_user_id, created_user_name, created_time) values (?, ?, ?, ?, ?, ?, ?, " . $site->db->unix2db_datetime(time()) . ", ?, ?, ?, ?, ?)", big_string_remove(strip_tags($site->fdat['pealkiri'])), $tyyp_id, $publish, $site->keel, 0, big_string_remove(strip_tags($site->fdat['pealkiri'])), big_string_remove(strip_tags($site->fdat['text'])), time(), 0, $site->user->id, $site->user->name, date("Y-m-d H:i:s"));
$sth = new SQL($sql);
$site->debug->msg($sth->debug->get_msgs());
$id = $sth->insert_id;
#####################
# insert into objekt_objekt:
$sql = "SELECT MAX(sorteering) FROM objekt_objekt";
$sth = new SQL($sql);
$site->debug->msg($sth->debug->get_msgs());
$sorteering = $sth->fetchsingle();
$sql = $site->db->prepare("INSERT INTO objekt_objekt (objekt_id, parent_id, sorteering) VALUES (?,?,?)", $id, $site->fdat['id'], $sorteering + 1);
$sth = new SQL($sql);
$site->debug->msg($sth->debug->get_msgs());
$name = big_string_remove(strip_tags($site->fdat['nimi']));
$email = strip_tags($site->fdat['email']);
$blog_url = strip_tags($site->fdat['url']);
#####################
# insert into obj_kommentaar:
$sql = $site->db->prepare("INSERT INTO obj_kommentaar (objekt_id, nimi, email, on_saada_email, on_peida_email, ip, text, kasutaja_id, url) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", $id, $name, $email, $site->fdat['on_saada_email'] ? 1 : 0, $site->fdat['on_peida_email'] ? 1 : 0, $_SERVER["REMOTE_ADDR"], big_string_remove(strip_tags($site->fdat['text'])), $site->user->user_id, $blog_url);
$sth = new SQL($sql);
$site->debug->msg($sth->debug->get_msgs());
$comment_inserted = $sth->rows;
#####################
# UPDATE LAST_COMMENTED_TIME, COMMENT_COUNT
# get comment count for object:
示例14: SQL
function get_default_profile_id()
{
$args = func_get_arg(0);
# source_table param is required
if (!$args['source_table']) {
return;
}
$sql = $this->db->prepare("SELECT profile_id FROM object_profiles WHERE source_table=? AND is_default=?", $args['source_table'], 1);
$sth = new SQL($sql);
return $sth->fetchsingle();
}
示例15: SQL
} else {
?>
<script type="text/javascript">
window.opener.location.href = window.opener.location.href.replace(/#$/, '');
window.close();
</script>
<?php
exit;
}
}
}
// get the extensions which have a default page template defined
// active template
$sql = "select page_ttyyp_id from keel where on_default = '1'";
$result = new SQL($sql);
$active_template_id = $result->fetchsingle();
// extensions with page templates
$extensions = array();
if ($site->fdat['extension']) {
$where = $site->db->prepare('and templ_tyyp.extension = ?', $site->fdat['extension']);
}
$sql = "select * from templ_tyyp where on_page_templ = '1' and is_default = 1 {$where}";
$result = new SQL($sql);
while ($template = $result->fetch('ASSOC')) {
if ($template['extension']) {
$extension = get_extensions('DB', false, $template['extension']);
$extension = $extension[$template['extension']];
// for sorting
$extension_titles[$extension['extension_id']] = $extension['title'];
// preview
if ($template['preview']) {