本文整理汇总了PHP中df_db函数的典型用法代码示例。如果您正苦于以下问题:PHP df_db函数的具体用法?PHP df_db怎么用?PHP df_db使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了df_db函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
function handle(&$params)
{
if (!@$_REQUEST['email']) {
return PEAR::raiseError("No email address specified");
}
import('HTML/QuickForm.php');
$form = new HTML_QuickForm('opt_out_form', 'post');
$form->addElement('hidden', 'email', $_REQUEST['email']);
$form->addElement('hidden', '-action', 'email_opt_out');
$form->addElement('submit', 'submit', 'Cancel Subscription');
if ($form->validate()) {
$res = mysql_query("replace into dataface__email_blacklist (email) values ('" . addslashes($_REQUEST['email']) . "')", df_db());
if (!$res) {
trigger_error(mysql_error(df_db()), E_USER_ERROR);
}
header('Location: ' . DATAFACE_SITE_HREF . '?--msg=' . urlencode('You have successfully opted out of our mail list. You will no longer receive emails from us.'));
exit;
}
ob_start();
$form->display();
$html = ob_get_contents();
ob_end_clean();
$context = array();
$context['form'] = $html;
df_register_skin('email', DATAFACE_PATH . '/modules/Email/templates');
df_display($context, 'email/opt_out_form.html');
}
示例2: performJobs
function performJobs()
{
if (!mutex('email.' . base64_encode(DATAFACE_SITE_PATH))) {
die("Email daemon already running");
}
$res = mysql_query("select * from dataface__email_jobs", df_db());
if (!$res) {
trigger_error(mysql_error(df_db()), E_USER_ERROR);
}
require_once DATAFACE_PATH . '/modules/Email/actions/email.php';
$action = new actions_email();
while ($row = mysql_fetch_assoc($res)) {
echo "\nSending mail for job {$row['job_id']} ...";
$res2 = mysql_query("delete from `" . $row['join_table'] . "` where recipient_email='' and messageid='" . addslashes($row['email_id']) . "'", df_db());
$action->sendMail($row['email_id'], $row['email_table'], $row['join_table'], $row['recipients_table'], $row['email_column']);
// check to see if all the messages for this job have been sent yet
$res2 = mysql_query("select count(*) from `" . $row['join_table'] . "` where sent<>1 and messageid='" . addslashes($row['email_id']) . "'", df_db());
if (!$res2) {
trigger_error(mysql_error(df_db()), E_USER_ERROR);
}
list($num) = mysql_fetch_row($res2);
@mysql_free_result($res2);
if ($num == 0) {
echo "\nJob {$row['job_id']} is complete! Deleting job...";
$res2 = mysql_query("delete from dataface__email_jobs where job_id='" . addslashes($row['job_id']) . "' limit 1", df_db());
if (!$res2) {
trigger_error(mysql_error(df_db()), E_USER_ERROR);
}
} else {
echo "\nAfter sending mail for job {$row['job_id']}, there are still {$num} messages left to send.";
}
}
@mysql_free_result($res);
echo "\n";
}
示例3: Dataface_PreferencesTool__createPreferencesTable
/**
* This function acts as a member method of the PreferencesTool class. It has
* been factored out for efficiency because it only needs to be run once.
* @see Dataface_PreferncesTool::_createPreferencesTable()
*/
function Dataface_PreferencesTool__createPreferencesTable()
{
$res = xf_db_query("create table if not exists `dataface__preferences` (\n\t\t\t`pref_id` int(11) unsigned not null auto_increment,\n\t\t\t`username` varchar(64) not null,\n\t\t\t`table` varchar(128) not null,\n\t\t\t`record_id` varchar(255) not null,\n\t\t\t`key` varchar(128) not null,\n\t\t\t`value` varchar(255) not null,\n\t\t\tprimary key (pref_id),\n\t\t\tindex `username` (`username`),\n\t\t\tindex `table` (`table`),\n\t\t\tindex `record_id` (`record_id`))", df_db());
if (!$res) {
throw new Exception(xf_db_error(df_db()), E_USER_ERROR);
}
}
示例4: handle
function handle(&$params)
{
$app =& Dataface_Application::getInstance();
$query = $app->getQuery();
$query['-skip'] = 0;
$query['-limit'] = 999999999;
$at = Dataface_ActionTool::getInstance();
$emailAction = $at->getAction(array('name' => 'email'));
if (!isset($emailAction) or !isset($emailAction['email_column'])) {
return PEAR::raiseError("No email column specified");
}
$col = $emailAction['email_column'];
$qb = new Dataface_QueryBuilder($query['-table'], $query);
$sql = "select `" . $col . "` " . $qb->_from() . $qb->_secure($qb->_where());
$res = mysql_query($sql, df_db());
if (!$res) {
trigger_error(mysql_error(df_db()), E_USER_ERROR);
}
$addresses = array();
while ($row = mysql_fetch_row($res)) {
$addresses[] = $row[0];
}
@mysql_free_result($res);
header("Content-type: text/plain");
echo implode(', ', $addresses);
exit;
}
示例5: __construct
/**
* @brief Initializes the datepicker module and registers all of the event listener.
*
*/
function __construct()
{
$app = Dataface_Application::getInstance();
// Now work on our dependencies
$mt = Dataface_ModuleTool::getInstance();
// We require the XataJax module
// The XataJax module activates and embeds the Javascript and CSS tools
$mt->loadModule('modules_XataJax', 'modules/XataJax/XataJax.php');
// Register the geopicker widget with the form tool so that it responds
// to widget:type=geopicker
import('Dataface/FormTool.php');
$ft = Dataface_FormTool::getInstance();
$ft->registerWidgetHandler('geopicker', dirname(__FILE__) . DIRECTORY_SEPARATOR . 'widget.php', 'Dataface_FormTool_geopicker');
if (!@$app->_conf['modules_geopicker'] or !@$app->_conf['modules_geopicker']['key']) {
$msg = <<<END
<p>Google Maps Module is installed but no API key is specified.</p>
<p>For information about obtaining your API key see <a href="https://developers.google.com/maps/documentation/javascript/tutorial#api_key">this page</a>.</p>
<p>After obtaining your key, add the following section to your application's conf.ini file:</p>
<p><code><pre>
[modules_geopicker]
key=YOUR_API_KEY_HERE
</pre></code></p>
END;
die($msg);
}
$app->addHeadContent('<script>XF_GEOPICKER_API_KEY="' . htmlspecialchars($app->_conf['modules_geopicker']['key']) . '";</script>');
foreach (Dataface_Table::loadTable('', df_db(), true) as $t) {
$evt = new StdClass();
$evt->table = $t;
$this->afterTableInit($evt);
}
$app->registerEventListener("afterTableInit", array($this, 'afterTableInit'));
$app->registerEventListener("Dataface_Record__htmlValue", array($this, 'Dataface_Record__htmlValue'));
}
示例6: q
static function q($sql)
{
$res = mysql_query($sql, df_db());
if (!$res) {
throw new Exception(mysql_error(df_db()));
}
return $res;
}
示例7: handle
function handle(&$params)
{
$app =& Dataface_Application::getInstance();
if (df_get_database_version() == df_get_file_system_version()) {
$app->redirect(DATAFACE_SITE_HREF . '?--msg=' . urlencode('The application database is up to date at version ' . df_get_database_version()));
}
if (df_get_database_version() > df_get_file_system_version()) {
$app->redirect(DATAFACE_SITE_HREF . '?--msg=' . urlencode('The database version is greater than the file system version. Please upgrade your application to match the version in the database (version ' . df_get_database_version()));
}
$res = xf_db_query("select count(*) from dataface__version", df_db());
if (!$res) {
throw new Exception(xf_db_error(df_db()));
}
$row = xf_db_fetch_row($res);
if ($row[0] == 0) {
$res2 = xf_db_query("insert into dataface__version (`version`) values (0)", df_db());
if (!$res2) {
throw new Exception(xf_db_error(df_db()));
}
}
if (file_exists('conf/Installer.php')) {
import('conf/Installer.php');
$installer = new conf_Installer();
$methods = get_class_methods('conf_Installer');
$methods = preg_grep('/^update_([0-9]+)$/', $methods);
$updates = array();
foreach ($methods as $method) {
preg_match('/^update_([0-9]+)$/', $method, $matches);
$version = intval($matches[1]);
if ($version > df_get_database_version() and $version <= df_get_file_system_version()) {
$updates[] = $version;
}
}
sort($updates);
foreach ($updates as $update) {
$method = 'update_' . $update;
$res = $installer->{$method}();
if (PEAR::isError($res)) {
return $res;
}
$res = xf_db_query("update dataface__version set `version`='" . addslashes($update) . "'", df_db());
if (!$res) {
throw new Exception(xf_db_error(df_db()), E_USER_ERROR);
}
}
}
$res = xf_db_query("update dataface__version set `version`='" . addslashes(df_get_file_system_version()) . "'", df_db());
if (!$res) {
throw new Exception(xf_db_error(df_db()), E_USER_ERROR);
}
if (function_exists('apc_clear_cache')) {
apc_clear_cache('user');
}
df_clear_views();
df_clear_cache();
$app->redirect(DATAFACE_SITE_HREF . '?--msg=' . urlencode('The database has been successfully updated to version ' . df_get_file_system_version()));
}
示例8: Dataface_ConfigTool_createConfigTable
/**
* A method to create the configuration table in the database. The configuration
* table is where configuration (e.g. fields.ini etc..) may be stored. This is
* a new feature in 0.6.14.
*
* @author Steve Hannah <shannah@sfu.ca>
* @created Feb. 26, 2007
*/
function Dataface_ConfigTool_createConfigTable()
{
$self =& Dataface_ConfigTool::getInstance();
if (!Dataface_Table::tableExists($self->configTableName, false)) {
$sql = "CREATE TABLE `" . $self->configTableName . "` (\n\t\t\t\t\tconfig_id int(11) NOT NULL auto_increment primary key,\n\t\t\t\t\t`file` varchar(255) NOT NULL,\n\t\t\t\t\t`section` varchar(128),\n\t\t\t\t\t`key` varchar(128) NOT NULL,\n\t\t\t\t\t`value` text NOT NULL,\n\t\t\t\t\t`lang` varchar(2),\n\t\t\t\t\t`username` varchar(32),\n\t\t\t\t\t`priority` int(5) default 5\n\t\t\t\t\t)";
$res = xf_db_query($sql, df_db());
if (!$res) {
throw new Exception(xf_db_error(df_db()), E_USER_ERROR);
}
}
}
示例9: createPortletWithSQL
public static function createPortletWithSQL($sql, $cols = null, $opts = array())
{
$db = new Database(df_db());
if (is_array($sql)) {
if (count($sql) > 1) {
$queryParams = $sql[1];
} else {
$queryParams = array();
}
$sql = $sql[0];
}
$rows = $db->query($sql, (object) $queryParams);
return new Portlet($rows, $cols, $opts);
}
示例10: get_user
function get_user($token = null)
{
$db = new Database(df_db());
if (!isset($token)) {
$token = $_POST['token'];
}
if (!$token) {
return null;
}
$user = $db->getObject("select username from sessions where token_id=:token_id and expires > :now", array('token_id' => $token, 'now' => time()));
if ($user) {
return $user->username;
}
return null;
}
示例11: Dataface_ConfigTool_setConfigParam
/**
* Sets a configuration parameter in the configuration table.
* This should not be called directly. It should be called through the
* Dataface_ConfigTool class as its setConfigParam method.
*
* @param string $file The name of the ini file in which the config value is being set.
* @param string $section The name of the section (could be null).
* @param string $key The name of the parameter's key (not null)
* @param string $value The value to set (not null)
* @param string $username The username for which the parameter is being set (null for all users)
* @param string $lang The 2-digit language code for which the parameter is being set (null for all languages).
* @param integer $priority The priority of this config variable (priority dictates which
* parameters take priority. Default vallue of 5.
* @returns true if success or PEAR_Error if failure.
*
* This will create the configuration table if it doesn't already exist.
*
* @author Steve Hannah <shannah@sfu.ca>
* @created Feb. 26, 2007
*/
function Dataface_ConfigTool_setConfigParam($file, $section, $key, $value, $username = null, $lang = null, $priority = 5)
{
$self =& Dataface_ConfigTool::getInstance();
// See if this parameter has already been set:
$where = array();
$where[] = "`key`='" . addslashes($key) . "'";
$where[] = "`file`='" . addslashes($file) . "'";
$where[] = "`section`" . (isset($section) ? "='" . addslashes($section) . "'" : ' IS NULL');
$where[] = "`username`" . (isset($username) ? "='" . addslashes($username) . "'" : ' IS NULL');
$where[] = "`lang`" . (isset($lang) ? "='" . addslashes($lang) . "'" : ' IS NULL');
$where = implode(' and ', $where);
$sql = "select `config_id` from `" . $self->configTableName . "` where {$where} limit 1";
$res = mysql_query($sql, df_db());
if (!$res) {
$self->createConfigTable();
$res = mysql_query($sql, df_db());
}
if (!$res) {
return PEAR::raiseError("Failed to get config parameter: " . mysql_error(df_db()));
}
$vals = array("section" => isset($section) ? "'" . addslashes($section) . "'" : 'NULL', "key" => "'" . addslashes($key) . "'", "value" => "'" . addslashes($value) . "'", "username" => "'" . addslashes($username) . "'", "lang" => "'" . addslashes($lang) . "'", "priority" => $priority);
if (mysql_num_rows($res) > 0) {
$row = mysql_fetch_assoc($res);
// We need to perform an update
$updates = array();
foreach ($vals as $vkey => $vval) {
$updates[] = '`' . $vkey . '`=' . $vval;
}
$sets = implode(' and ', $updates);
$sql = "update `" . $self->configTableName . "` set " . $sets . " where `config_id`='" . $row['config_id'] . "' limit 1";
} else {
$values = array();
$cols = array();
foreach ($vals as $vkey => $vval) {
$cols[] = "`{$vkey}`";
$values[] = $vval;
}
$cols = implode(',', $cols);
$values = implode(',', $values);
$sql = "insert into `" . $self->configTableName . "` ({$cols}) VALUES ({$values})";
}
@mysql_free_result($res);
$res = mysql_query($sql, df_db());
if (!$res) {
return PEAR::raiseError("Could not write config value: " . mysql_error(df_db()));
}
return true;
}
示例12: q
public static function q($sql)
{
if (is_array($sql)) {
$res = null;
foreach ($sql as $q) {
$res = self::q($q);
}
return $res;
} else {
$res = mysql_query($sql, df_db());
if (!$res) {
throw new Exception(mysql_error(df_db()));
}
return $res;
}
}
示例13: handle
function handle(&$params)
{
$app =& Dataface_Application::getInstance();
$query =& $app->getQuery();
$mt =& Dataface_ModuleTool::getInstance();
$mod =& $mt->loadModule('modules_DataGrid');
if (PEAR::isError($mod)) {
return $mod;
}
$res = mysql_query("select gridID,gridName from dataface__DataGrids where tableName='" . addslashes($query['-table']) . "'", df_db());
$grids = array();
while ($row = mysql_fetch_assoc($res)) {
$grids[$row['gridID']] = array('name' => $row['gridName'], 'url' => $app->url('-gridid=' . $row['gridID'] . '&-action=DataGrid_view'));
}
//print_r($grids);
df_register_skin('DataGrid', DATAFACE_PATH . '/modules/DataGrid/templates');
df_display(array('grids' => $grids), 'DataGrid/list.html');
}
示例14: handle
function handle(&$params)
{
$res = xf_db_query("show tables like 'dataface__view_%'", df_db());
$views = array();
while ($row = xf_db_fetch_row($res)) {
$views[] = $row[0];
}
if ($views) {
$sql = "drop view `" . implode('`,`', $views) . "`";
echo $sql;
echo "<br/>";
$res = xf_db_query("drop view `" . implode('`,`', $views) . "`", df_db());
if (!$res) {
throw new Exception(xf_db_error(df_db()));
}
}
echo "done";
}
示例15: saveDataGrid
function saveDataGrid($grid)
{
if ($grid->id) {
$idName = 'gridID,';
$idVal = "'" . addslashes($grid->id) . "',";
} else {
$idName = '';
$idVal = '';
}
$sql = "replace into dataface__DataGrids \n\t\t\t(" . $idName . "gridName,gridData,tableName)\n\t\t\tvalues\n\t\t\t(" . $idVal . "'" . addslashes($grid->name) . "',\n\t\t\t'" . addslashes(serialize($grid)) . "',\n\t\t\t'" . addslashes($grid->tableName) . "')";
$res = mysql_query($sql, df_db());
if (!$res) {
trigger_error(mysql_error(df_db()), E_USER_ERROR);
}
if (!$grid->id) {
$grid->id = mysql_insert_id(df_db());
return $this->saveDataGrid($grid);
}
return true;
}