本文整理汇总了PHP中_sql函数的典型用法代码示例。如果您正苦于以下问题:PHP _sql函数的具体用法?PHP _sql怎么用?PHP _sql使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了_sql函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: v
function v($k, $v = false, $nr = false)
{
$a = isset($this->config[$k]) ? $this->config[$k] : false;
if ($nr !== false && $v !== false) {
$this->config[$k] = $v;
return $v;
}
if ($v !== false) {
$sql_update = array('config_value' => $v);
if ($a !== false) {
$sql = 'UPDATE _config SET ' . _build_array('UPDATE', $sql_update) . sql_filter('
WHERE config_name = ?', $k);
} else {
$sql_update['config_name'] = $k;
$sql = 'INSERT INTO _config' . _build_array('INSERT', $sql_update);
}
_sql($sql);
$this->config[$k] = $a = $v;
}
return $a;
}
示例2: home
public function home()
{
global $user;
$v = $this->__(w('alias filename ext'));
if (!f($v['alias']) || !f($v['filename'])) {
_fatal();
}
$sql = 'SELECT tree_id
FROM _tree
WHERE tree_alias = ?';
if (!($tree = _fieldrow(sql_filter($sql, $v['alias'])))) {
_fatal();
}
$sql = 'SELECT *
FROM _downloads
WHERE download_alias = ?
AND download_tree = ?';
if (!($download = _fieldrow(sql_filter($sql, $v['filename'], $tree['tree_id'])))) {
_fatal();
}
if ($download['download_login']) {
_login();
}
$sql = 'UPDATE _downloads SET download_count = download_count + 1
WHERE download_id = ?';
_sql(sql_filter($sql, $download['download_id']));
$filepath = LIB . 'fetch/' . _filename($download['download_id'], $download['download_extension']);
return;
}
示例3: sqlresult
function sqlresult($sql)
{
$result = '';
$tt1 = _sql($sql);
if (@mysql_num_rows($tt1) > 0) {
$result = mysql_result($tt1, 0);
}
@mysql_free_result($tt1);
return $result;
}
示例4: _create_home
protected function _create_home()
{
if (_button()) {
$v = $this->__(array('codigo', 'nombre', 'apellido', 'direccion', 'edad', 'sexo', 'email', 'telefono', 'identificacion', 'status', 'carne', 'carne_auto' => 0));
/*
padre_nombre
padre_apellido
madre_nombre
madre_apellido
encargado_nombre
encargado_apellido
encargado_profesion
encargado_labora
encargando_labora_direccion
encargado_identificacion
encargado_emergencia
*/
$sql = 'INSERT INTO _students' . _build_array('INSERT', $v);
$v['id'] = _sql_nextid($sql);
if ($v['carne_auto']) {
$v['carne'] = date('Y') . $v['id'];
$sql = 'UPDATE _students SET carne = ?
WHERE id_alumno = ?';
_sql(sql_filter($sql, $v['carne'], $v['id']));
}
$sql_insert = '';
// TODO: Build query
$sql = 'INSERT INTO _registrations' . _build_array('INSERT', '');
}
$sql = 'SELECT grade_id, grade_name
FROM _grades
WHERE grade_status = 1
ORDER BY grade_order';
$grades = _rowset($sql);
foreach ($grades as $i => $row) {
if (!$i) {
_style('grades');
}
_style('grades.row', array('GRADE_ID' => $row['grade_id'], 'GRADE_NAME' => $row['grade_name']));
}
$sql = 'SELECT section_id, section_name
FROM _sections
WHERE section_grade = 1';
$sections = _rowset($sql);
foreach ($sections as $i => $row) {
if (!$i) {
_style('sections');
}
_style('sections.row', array('SECTION_ID' => $row['section_id'], 'SECTION_NAME' => $row['section_name']));
}
return;
}
示例5: home
public function home()
{
$sql = 'SELECT *
FROM _store s, _store_fields f
WHERE s.store_field = f.field_id
ORDER BY store_field';
$store = _rowset($sql, 'store_assoc', false, true);
$a_country = array('Alemania' => 82, 'Argentina' => 10, 'Bolivia' => 26, 'Chile' => 43, 'Colombia' => 47, 'Ecuador' => 63, 'El Salvador' => 65, 'Espana' => 197, 'Francia' => 74, 'Greece' => 85, 'Guatemala' => 90, 'Honduras' => 97, 'Italia' => 107, 'Mexico' => 140, 'Paraguay' => 168, 'Peru' => 169, 'Uruguay' => 227, 'Venezuela' => 230);
foreach ($store as $i => $row) {
$nickname = '';
$address = '';
$birthday = '';
$country = '';
foreach ($row as $field) {
switch ($field['field_alias']) {
case 'nickname':
$nickname = $field['store_value'];
break;
case 'address':
$address = $field['store_value'];
break;
case 'birthday':
$temp = explode('/', $field['store_value']);
$birthday = $temp[2] . '' . $temp[1] . '' . $temp[0];
break;
case 'country':
$country = $a_country[$field['store_value']];
break;
}
}
$sql_insert = array('type' => 1, 'active' => 0, 'username' => $nickname, 'password' => '', 'registration' => time(), 'lastvisit' => 0, 'lastpage' => '', 'country' => $country, 'email' => $address, 'birthday' => $birthday, 'birthday_last' => 0, 'gender' => 0, 'date' => 0, 'dateformat' => 'd M Y H:i', 'timezone' => -6, 'dst' => 0, 'login_tries' => 0);
$sql = 'INSERT INTO _members' . _build_array('INSERT', prefix('user', $sql_insert));
_sql($sql);
//_pre($sql);
}
$this->e('Done.');
return;
}
示例6: home
function home()
{
$sql = 'SELECT *
FROM _members
WHERE user_type = ?
AND user_birthday LIKE ?
AND user_birthday_last < ?
ORDER BY user_username
LIMIT ??';
$birthday = _rowset(sql_filter($sql, 1, '%' . date('md'), date('Y'), 10));
if (!$birthday) {
$this->e('None.');
}
$process = w();
foreach ($birthday as $i => $row) {
if (!$i) {
@set_time_limit(0);
require XFS . 'core/emailer.php';
$emailer = new emailer();
}
$emailer->format('plain');
$emailer->from('TWC Kaulitz <twc_princess@twckaulitz.com>');
$emailer->use_template('user_birthday');
$emailer->email_address($row['user_email']);
$emailer->assign_vars(array('USERNAME' => $row['user_username']));
$emailer->send();
$emailer->reset();
$process[$row['user_id']] = $row['user_username'];
}
if (count($process)) {
$sql = 'UPDATE _members SET user_birthday_last = ?
WHERE user_id IN (??)';
_sql(sql_filter($sql, date('Y'), _implode(',', array_keys($process))));
}
return $this->e('Done @ ' . implode(',', array_values($process)));
}
示例7: _groups_remove
protected function _groups_remove()
{
gfatal();
global $core;
$v = $this->__(array('el' => 0));
$sql = 'SELECT group_id
FROM _groups
WHERE group_id = ?';
if (!($group = _fieldrow(sql_filter($sql, $v['el'])))) {
$this->_error('#GROUPS_NO_EXISTS');
}
$sql = 'SELECT ticket_id
FROM _tickets
WHERE ticket_group = ?';
if (_fieldrow(sql_filter($sql, $v['el']))) {
$this->_error('#GROUP_CANT_REMOVE_TICKETS');
}
$sql = 'DELETE FROM _groups
WHERE group_id = ?';
_sql(sql_filter($sql, $v['el']));
$sql = 'DELETE FROM _groups_members
WHERE member_group = ?';
_sql(sql_filter($sql, $v['el']));
$core->cache_unload();
return $this->e('~OK');
}
示例8: home
public function home()
{
global $core;
error_reporting(0);
$v = $this->__(w('v'));
if (!$v['v']) {
$sql = 'SELECT media_id
FROM _bio_media
WHERE media_type = ?
AND media_mp3 = ?
LIMIT 1';
$v['v'] = _field(sql_filter($sql, 1, 0), 'media_id', 0);
}
$tag_format = 'UTF-8';
$relative_path = '/data/artists/%s/media/';
$absolute_path = '/var/www/vhosts/rockrepublik.net/www' . $relative_path;
$sql = 'SELECT m.*, b.bio_id, b.bio_name
FROM _bio_media m
LEFT JOIN _bio b ON m.media_bio = b.bio_id
WHERE m.media_id = ?';
//$spaths = '/data/artists/' . $songd['ub'] . '/media/';
//$spath = '/var/www/vhosts/rockrepublik.net/httpdocs' . $spaths;
if ($media = _fieldrow(sql_filter($sql, $v['v']))) {
$row_relative = sprintf($relative_path, $media['bio_id']);
$row_absolute = $absolute_path . $row_relative;
$row_wma = $row_absolute . $media['media_id'] . '.wma';
$row_mp3 = $row_absolute . $media['media_id'] . '.mp3';
$rel_wma = '.' . $row_relative . $media['media_id'] . '.wma';
$rel_mp3 = '.' . $row_relative . $media['media_id'] . '.mp3';
if (@file_exists($rel_wma) && !@file_exists($rel_mp3) && !$media['media_mp3']) {
exec('ffmpeg -i ' . $row_wma . ' -vn -ar 44100 -ac 2 -ab 64kb -f mp3 ' . $row_mp3);
include_once XFS . XCOR . 'getid3/getid3.php';
$getID3 = new getID3();
$getID3->setOption(array('encoding' => $tag_format));
getid3_lib::IncludeDependency(GETID3_INCLUDEPATH . 'write.php', __FILE__, true);
$tagwriter = new getid3_writetags();
$tagwriter->filename = getid3_lib::SafeStripSlashes($row_mp3);
$tagwriter->tagformats = array('id3v1');
$tagwriter->overwrite_tags = true;
$tagwriter->tag_encoding = $tag_format;
$tagwriter->remove_other_tags = true;
$tag_comment = 'Visita www.rockrepublik.net';
$media['album'] = !empty($media['media_album']) ? $media['media_album'] : 'Single';
$media['genre'] = !empty($media['media_genre']) ? $media['media_genre'] : 'Rock';
$media_f = array('title', 'name', 'album', 'genre');
foreach ($media_f as $mr) {
$media['media_' . $mr] = getid3_lib::SafeStripSlashes(utf8_encode(html_entity_decode($media['media_' . $mr])));
}
$tagwriter->tag_data = array('title' => array($media['media_title']), 'artist' => array($media['media_name']), 'album' => array($media['media_album']), 'year' => array(getid3_lib::SafeStripSlashes($media['media_year'])), 'genre' => array($media['media_genre']), 'comment' => array(getid3_lib::SafeStripSlashes($tag_comment)), 'tracknumber' => array(''));
$tagwriter->WriteTags();
$sql = 'UPDATE _bio_media SET media_mp3 = ?
WHERE media_id = ?';
_sql(sql_filter($sql, 1, $media['media_id']));
$fp = @fopen('./conv.txt', 'a+');
fwrite($fp, $row_mp3 . "\n");
fclose($fp);
}
if (!@file_exists($rel_wma)) {
$sql = 'UPDATE _bio_media SET media_mp3 = ?
WHERE media_id = ?';
_sql(sql_filter($sql, 2, $media['media_id']));
}
}
$sql = 'SELECT media_id
FROM _bio_media
WHERE media_type = ?
AND media_mp3 = ?
LIMIT 1';
if ($v_next = _field(sql_filter($sql, 1, 0), 'media_id', 0)) {
sleep(1);
_redirect(_link($this->m(), array('v' => $v_next)));
} else {
$this->e('no_next');
}
return $this->e('.');
}
示例9: change_database_data
/**
* Function where all data changes are executed
*/
function change_database_data(&$no_updates, $version)
{
global $db, $map_dbms, $errored, $error_ary, $config, $phpbb_root_path;
switch ($version) {
case '2.0.B3':
_sql('INSERT INTO ' . GARAGE_CONFIG_TABLE . " (config_name, config_value) VALUES ('enable_blogs_smilies', '1')", $errored, $error_ary);
_sql('INSERT INTO ' . GARAGE_CONFIG_TABLE . " (config_name, config_value) VALUES ('enable_blogs_url', '1')", $errored, $error_ary);
_sql('INSERT INTO ' . GARAGE_CONFIG_TABLE . " (config_name, config_value) VALUES ('enable_make_approval', '1')", $errored, $error_ary);
_sql('INSERT INTO ' . GARAGE_CONFIG_TABLE . " (config_name, config_value) VALUES ('enable_model_approval', '1')", $errored, $error_ary);
_sql('INSERT INTO ' . GARAGE_CONFIG_TABLE . " (config_name, config_value) VALUES ('enable_guestbooks_url', '1')", $errored, $error_ary);
_sql('INSERT INTO ' . GARAGE_CONFIG_TABLE . " (config_name, config_value) VALUES ('enable_guestbooks_smilies', '1')", $errored, $error_ary);
$no_updates = false;
break;
}
}
示例10: _attend_home
protected function _attend_home()
{
global $bio;
if (!is_ghost()) {
_fatal();
}
if (!$bio->v('auth_member')) {
_login();
}
$v = $this->__(_array_keys(w('event option'), 0));
if (!$v['event'] || !$v['option']) {
_fatal();
}
$sql = 'SELECT event_id
FROM _events
WHERE event_id = ?';
if (!_fieldrow($sql, $v['event'])) {
_fatal();
}
$sql = 'SELECT type_id
FROM _events_attend_type
WHERE type_id = ?';
if (!_fieldrow(sql_filter($sql, $v['option']))) {
_fatal();
}
$sql = 'SELECT attend_id
FROM _events_attend
WHERE attend_event = ?
AND attend_uid = ?';
if ($attend_id = _field(sql_filter($sql, $v['event'], $bio->v('bio_id')), 'attend_id', 0)) {
$sql = 'UPDATE _events SET attend_option = ?
WHERE attend_id = ?';
_sql(sql_filter($sql, $v['option'], $attend_id));
} else {
$sql_insert = array('attend_event' => $v['event'], 'attend_uid' => $bio->v('bio_id'), 'attend_option' => $v['option'], 'attend_time' => time());
sql_put('_events_attend', $sql_insert);
}
return $this->e('~OK');
}
示例11: _friend_deny
protected function _friend_deny()
{
global $bio;
if (!$bio->v('auth_member')) {
_login();
}
$v = $this->__(w('a'));
$sql = 'SELECT bio_id
FROM _bio
WHERE bio_alias = ?';
if (!($bio_id = _field(sql_filter($sql, $v['a']), 'bio_id', 0))) {
_fatal();
}
$sql = 'SELECT friend_id, friend_pending
FROM _bio_friends
WHERE friend_assoc = ?
AND friend_bio = ?';
if (!($friend = _fieldrow(sql_filter($sql, $bio_id, $bio->v('bio_id'))))) {
_fatal();
}
if (!$friend['friend_pending']) {
_fatal();
}
$sql = 'DELETE FROM _bio_friends
WHERE friend_id = ?';
_sql(sql_filter($sql, $friend['friend_id']));
return;
}
示例12: _members_profile
protected function _members_profile()
{
global $bio;
$sql = 'SELECT *
FROM _bio_store
ORDER BY a_field';
$profiles = _rowset($sql);
foreach ($profiles as $row) {
$field_id = 0;
if (isset($cache[$row['a_field']])) {
$field_id = $cache[$row['a_field']];
}
if (!$field_id) {
$sql = 'SELECT *
FROM _bio_fields
WHERE field_display = ?';
if ($members_fields = _fieldrow(sql_filter($sql, $row['a_field']))) {
$field_id = $members_fields['field_id'];
$cache[$row['a_field']] = $field_id;
}
}
if (!$field_id) {
$sql_insert = array('field_alias' => $row['a_field'], 'field_name' => $row['a_field'], 'field_display' => $row['a_field'], 'field_required' => 0, 'field_unique' => 0, 'field_unique_global' => 0, 'field_show' => 1, 'field_length' => 0, 'field_type' => 'text', 'field_relation' => '', 'field_function' => '', 'field_js' => '');
$field_id = sql_put('_bio_fields', $sql_insert);
}
$sql = 'UPDATE _bio_store SET a_field = ?
WHERE a_id = ?';
_sql(sql_filter($sql, $field_id, $row['a_id']));
}
$sql = "ALTER TABLE _bio_store\r\n\t\t\tCHANGE a_field a_field INT(11) NOT NULL DEFAULT '0'";
_sql($sql);
$this->_e('Done!');
return;
}
示例13: _download_home
protected function _download_home()
{
global $user;
$v = $this->__(array('f'));
if (!f($v['f'])) {
_fatal();
}
$sql = 'SELECT *
FROM _downloads
WHERE download_alias = ?';
if (!($download = _fieldrow(sql_filter($sql, $v['f'])))) {
_fatal();
}
$sql = 'UPDATE _downloads
SET download_count = download_count + 1
WHERE download_id = ?';
_sql(sql_filter($sql, $download['download_id']));
sql_close();
$orig = array('#\\.#', '#\\&(\\w)(acute|tilde)\\;#');
$repl = array('', '\\1');
$bad_chars = array("'", "\\", ' ', '/', ':', '*', '?', '"', '<', '>', '|');
$filename = preg_replace($orig, $repl, $download['download_title']) . '.' . $download['download_extension'];
$filename = preg_replace("/%(\\w{2})/", '_', rawurlencode(str_replace($bad_chars, '_', $filename)));
$filepath = LIB . 'get/' . $download['download_id'] . '.' . $download['download_extension'];
// Headers
header('Content-Type: application/octet-stream; name="' . $filename . '"');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('Accept-Ranges: bytes');
header('Pragma: no-cache');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-transfer-encoding: binary');
header('Content-length: ' . @filesize($filepath));
@readfile($filepath);
exit;
}
示例14: change_database_data
function change_database_data(&$no_updates, $version)
{
global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx;
switch ($version)
{
case '3.0.0':
$sql = 'UPDATE ' . TOPICS_TABLE . "
SET topic_last_view_time = topic_last_post_time
WHERE topic_last_view_time = 0";
_sql($sql, $errored, $error_ary);
// Update smiley sizes
$smileys = array('icon_e_surprised.gif', 'icon_eek.gif', 'icon_cool.gif', 'icon_lol.gif', 'icon_mad.gif', 'icon_razz.gif', 'icon_redface.gif', 'icon_cry.gif', 'icon_evil.gif', 'icon_twisted.gif', 'icon_rolleyes.gif', 'icon_exclaim.gif', 'icon_question.gif', 'icon_idea.gif', 'icon_arrow.gif', 'icon_neutral.gif', 'icon_mrgreen.gif', 'icon_e_ugeek.gif');
foreach ($smileys as $smiley)
{
if (file_exists($phpbb_root_path . 'images/smilies/' . $smiley))
{
list($width, $height) = getimagesize($phpbb_root_path . 'images/smilies/' . $smiley);
$sql = 'UPDATE ' . SMILIES_TABLE . '
SET smiley_width = ' . $width . ', smiley_height = ' . $height . "
WHERE smiley_url = '" . $db->sql_escape($smiley) . "'";
_sql($sql, $errored, $error_ary);
}
}
$no_updates = false;
break;
// No changes from 3.0.1-RC1 to 3.0.1
case '3.0.1-RC1':
break;
// changes from 3.0.1 to 3.0.2-RC1
case '3.0.1':
set_config('referer_validation', '1');
set_config('check_attachment_content', '1');
set_config('mime_triggers', 'body|head|html|img|plaintext|a href|pre|script|table|title');
$no_updates = false;
break;
// No changes from 3.0.2-RC1 to 3.0.2-RC2
case '3.0.2-RC1':
break;
// No changes from 3.0.2-RC2 to 3.0.2
case '3.0.2-RC2':
break;
// Changes from 3.0.2 to 3.0.3-RC1
case '3.0.2':
set_config('enable_queue_trigger', '0');
set_config('queue_trigger_posts', '3');
set_config('pm_max_recipients', '0');
// Set maximum number of recipients for the registered users, bots, guests group
$sql = 'UPDATE ' . GROUPS_TABLE . ' SET group_max_recipients = 5
WHERE ' . $db->sql_in_set('group_name', array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA', 'BOTS'));
_sql($sql, $errored, $error_ary);
// Not prefilling yet
set_config('dbms_version', '');
// Add new permission u_masspm_group and duplicate settings from u_masspm
include_once($phpbb_root_path . 'includes/acp/auth.' . $phpEx);
$auth_admin = new auth_admin();
// Only add the new permission if it does not already exist
if (empty($auth_admin->acl_options['id']['u_masspm_group']))
{
$auth_admin->acl_add_option(array('global' => array('u_masspm_group')));
// Now the tricky part, filling the permission
$old_id = $auth_admin->acl_options['id']['u_masspm'];
$new_id = $auth_admin->acl_options['id']['u_masspm_group'];
$tables = array(ACL_GROUPS_TABLE, ACL_ROLES_DATA_TABLE, ACL_USERS_TABLE);
foreach ($tables as $table)
{
$sql = 'SELECT *
FROM ' . $table . '
WHERE auth_option_id = ' . $old_id;
$result = _sql($sql, $errored, $error_ary);
$sql_ary = array();
while ($row = $db->sql_fetchrow($result))
{
$row['auth_option_id'] = $new_id;
$sql_ary[] = $row;
}
$db->sql_freeresult($result);
//.........这里部分代码省略.........
示例15: _gallery_create
public function _gallery_create()
{
global $bio, $core;
if (_button()) {
$upload = _import('upload');
// Start
$sql = 'SELECT MAX(image_id) AS total
FROM _bio_images
WHERE image_bio = ?';
$image = sql_field(sql_filter($sql, $this->a('bio_id')), 'total', 0) + 1;
$upload->chmod(array(_lib(LIB_BIO . ' ' . $this->a('bio_id'))), 0777);
$f = $upload->process(LIB . 'tmp/', request_var('files:picture'), w('jpg'), $core->v('max_upload'));
if ($f === false && count($upload->error)) {
$warning->set($upload->error);
}
if (!$warning->exist) {
$total = 0;
foreach ($f as $row) {
//$row = $upload->_row($gallery, $image);
$f2 = $upload->resize($row, LIB . 'tmp', LIB . 'events/future/', $v['e_id'], array(600, 400), false, false, true);
if ($f2 === false) {
continue;
}
$f3 = $upload->resize($row, LIB . 'events/future/', LIB . 'events/preview/', $v['e_id'], array(210, 210), false, false);
$total++;
//
$sql_insert = array('bio' => $bio->v('bio_id'), 'image' => $image, 'width' => $i_data['width'], 'height' => $i_data['height'], 'views' => 0, 'downloads' => 0, 'allow_dl' => (int) $allow_dl);
sql_put('_bio_images', prefix('image', $sql_insert));
$image++;
}
$sql = 'UPDATE _bio_store SET store_value = store_value + ??
WHERE store_bio = ?';
_sql(sql_filter($sql, $total, $bio->v('bio_id')));
}
if (!$error) {
redirect(_link_control('a', array('a' => $bio->v('bio_alias'), 'x1' => $this->x(1))));
}
}
return v_style(array('U_CREATE' => _link_bio($bio->v('bio_alias'), array('x1' => $this->x(1), 'x2' => $this->x(2))), 'MAX_FILESIZE' => $core - v('max_upload')));
}