• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP is_mysql函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中is_mysql函数的典型用法代码示例。如果您正苦于以下问题:PHP is_mysql函数的具体用法?PHP is_mysql怎么用?PHP is_mysql使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了is_mysql函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: xmldb_blocktype_textbox_upgrade

function xmldb_blocktype_textbox_upgrade($oldversion = 0)
{
    if ($oldversion < 2011082200) {
        // Convert all textbox html content to artefacts
        $tbcount = count_records('block_instance', 'blocktype', 'textbox');
        $sql = '
            SELECT b.id, b.title, b.configdata, b.view,
                v.owner, v.group, v.institution, v.ctime, v.mtime, v.atime
            FROM {block_instance} b JOIN {view} v ON b.view = v.id
            WHERE b.id > ? AND b.blocktype = ?
            ORDER BY b.id';
        $done = 0;
        $lastid = 0;
        if (is_mysql()) {
            $mp = mysql_get_variable('max_allowed_packet');
            $limit = $mp && is_numeric($mp) && $mp > 1048576 ? $mp / 8192 : 100;
        } else {
            $limit = 5000;
        }
        while ($records = get_records_sql_array($sql, array($lastid, 'textbox'), 0, $limit)) {
            // Create the new artefacts
            $values = array();
            foreach ($records as $r) {
                $configdata = unserialize($r->configdata);
                array_push($values, 'html', $r->ctime, $r->mtime, $r->atime, $r->title, isset($configdata['text']) ? $configdata['text'] : '', $r->owner, $r->group, $r->institution, $r->owner > 0 ? $r->owner : null, $r->owner > 0 ? null : '?', $r->id);
                // Dumping the block id in the note column makes it easier to update block_instance later
            }
            $insertsql = "\n                INSERT INTO {artefact}\n                    (artefacttype, ctime, mtime, atime, title, description, owner, \"group\", institution, author, authorname, note)\n                VALUES ";
            $insertsql .= join(',', array_fill(0, count($records), '(?,?,?,?,?,?,?,?,?,?,?,?)'));
            execute_sql($insertsql, $values);
            // Update block_instance configdata to point at the new artefacts
            if (is_postgres()) {
                execute_sql("\n                    UPDATE {block_instance}\n                    SET configdata = 'a:1:{s:10:\"artefactid\";i:' || a.id::text || ';}'\n                    FROM (\n                        SELECT id, note FROM {artefact} WHERE artefacttype = 'html' AND note IS NOT NULL\n                    ) a\n                    WHERE blocktype = 'textbox' AND {block_instance}.id::text = a.note");
                // Update view_artefact table
                execute_sql("\n                    INSERT INTO {view_artefact} (view, block, artefact)\n                    SELECT b.view, b.id, a.id\n                    FROM {block_instance} b, {artefact} a\n                    WHERE b.blocktype = 'textbox' AND a.artefacttype = 'html' AND a.note IS NOT NULL AND CAST(b.id AS TEXT) = a.note", array());
            } else {
                if (is_mysql()) {
                    execute_sql("\n                    UPDATE {block_instance}, {artefact}\n                    SET {block_instance}.configdata = CONCAT('a:1:{s:10:\"artefactid\";i:', {artefact}.id, ';}')\n                    WHERE\n                        {artefact}.artefacttype = 'html'\n                        AND {artefact}.note IS NOT NULL\n                        AND {block_instance}.blocktype = 'textbox'\n                        AND {block_instance}.id = {artefact}.note");
                    // Update view_artefact table
                    execute_sql("\n                    INSERT INTO {view_artefact} (view, block, artefact)\n                    SELECT b.view, b.id, a.id\n                    FROM {block_instance} b, {artefact} a\n                    WHERE b.blocktype = 'textbox' AND a.artefacttype = 'html' AND a.note IS NOT NULL AND b.id = a.note", array());
                }
            }
            // Remove the dodgy block id in the note column
            execute_sql("UPDATE {artefact} SET note = NULL WHERE artefacttype = 'html' AND note IS NOT NULL");
            $done += count($records);
            log_debug("Upgrading textbox blocks: {$done}/{$tbcount}");
            $last = end($records);
            $lastid = $last->id;
        }
    }
    return true;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:52,代码来源:upgrade.php


示例2: postinst

 public static function postinst($prevversion)
 {
     if ($prevversion == 0) {
         // MySQL can't handle uniqueness of > 255 chars
         if (is_postgres()) {
             execute_sql('CREATE UNIQUE INDEX {blocextedata_url_uix} ON {blocktype_externalfeed_data}(url);');
         } else {
             if (is_mysql()) {
                 execute_sql('ALTER TABLE {blocktype_externalfeed_data} ADD UNIQUE {blocextedata_url_uix} (url(255))');
             } else {
                 // TODO: support other databases
             }
         }
     }
 }
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:15,代码来源:lib.php


示例3: postinst

 public static function postinst($prevversion)
 {
     if ($prevversion == 0) {
         if (is_postgres()) {
             $table = new XMLDBTable('blocktype_externalfeed_data');
             $index = new XMLDBIndex('urlautautix');
             $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('url', 'authuser', 'authpassword'));
             add_index($table, $index);
         } else {
             if (is_mysql()) {
                 // MySQL needs size limits when indexing text fields
                 execute_sql('ALTER TABLE {blocktype_externalfeed_data} ADD INDEX
                            {blocextedata_urlautaut_ix} (url(255), authuser(255), authpassword(255))');
             }
         }
     }
 }
开发者ID:vohung96,项目名称:mahara,代码行数:17,代码来源:lib.php


示例4: xmldb_blocktype_externalfeed_upgrade

function xmldb_blocktype_externalfeed_upgrade($oldversion = 0)
{
    if ($oldversion < 2008042100) {
        // Add the 'image' column so that information about a feed's image can
        // be stored
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $field = new XMLDBField('image');
        $field->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field);
    }
    if ($oldversion < 2008042101) {
        // We hit the 255 character limit for feed URLs
        if (is_postgres()) {
            execute_sql('ALTER TABLE {blocktype_externalfeed_data} ALTER COLUMN url TYPE TEXT');
        } else {
            if (is_mysql()) {
                // If 2 URLs > 255 chars have the same first 255 characters then mahara will error - this is a MySQL issue though, their unique key length limit is to blame
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} DROP KEY {blocextedata_url_uix}');
                // We have to remove then add the constraint again else the change will make MySQL cry
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} MODIFY COLUMN "url" text');
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} add unique {blocextedata_url_uix} (url(255))');
            }
        }
    }
    if ($oldversion < 2009121600) {
        if (is_mysql()) {
            // Make content column wider (TEXT is only 65kb in mysql)
            $table = new XMLDBTable('blocktype_externalfeed_data');
            $field = new XMLDBField('content');
            $field->setAttributes(XMLDB_TYPE_TEXT, "big", null, null);
            change_field_precision($table, $field);
        }
    }
    if ($oldversion < 2010073000) {
        execute_sql('
            UPDATE {blocktype_cron}
            SET minute = ?
            WHERE minute = ? AND hour = ? AND plugin = ? AND callfunction = ?', array('30', '0', '3', 'externalfeed', 'cleanup_feeds'));
    }
    return true;
}
开发者ID:richardmansfield,项目名称:richardms-mahara,代码行数:41,代码来源:upgrade.php


示例5: xmldb_notification_internal_upgrade

function xmldb_notification_internal_upgrade($oldversion = 0)
{
    if ($oldversion < 2011112300) {
        execute_sql("\n            UPDATE {notification_internal_activity}\n            SET url = REPLACE(url, ?, '')\n            WHERE url IS NOT NULL", array(get_config('wwwroot')));
    }
    if ($oldversion < 2012021000) {
        // Populate the unread count on the usr table
        if (is_postgres()) {
            execute_sql('
                UPDATE {usr} SET unread = n.unread FROM (
                    SELECT usr, SUM(1 - read) AS unread FROM {notification_internal_activity} GROUP BY usr
                ) n WHERE {usr}.id = n.usr;');
        } else {
            if (is_mysql()) {
                execute_sql('
                UPDATE {usr} u, (SELECT usr, SUM(1 - "read") AS unread FROM {notification_internal_activity} GROUP BY usr) n
                SET u.unread = n.unread
                WHERE u.id = n.usr');
            }
        }
        // Create triggers to maintain the unread count
        db_create_trigger('update_unread_insert', 'AFTER', 'INSERT', 'notification_internal_activity', '
            IF NEW.read = 0 THEN
                UPDATE {usr} SET unread = unread + 1 WHERE id = NEW.usr;
            END IF;');
        db_create_trigger('update_unread_update', 'AFTER', 'UPDATE', 'notification_internal_activity', '
            IF OLD.read = 0 AND NEW.read = 1 THEN
                UPDATE {usr} SET unread = unread - 1 WHERE id = NEW.usr;
            ELSEIF OLD.read = 1 AND NEW.read = 0 THEN
                UPDATE {usr} SET unread = unread + 1 WHERE id = NEW.usr;
            END IF;');
        db_create_trigger('update_unread_delete', 'AFTER', 'DELETE', 'notification_internal_activity', '
            IF OLD.read = 0 THEN
                UPDATE {usr} SET unread = unread - 1 WHERE id = OLD.usr;
            END IF;');
    }
    return true;
}
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:38,代码来源:upgrade.php


示例6: upgrade_8

function upgrade_8()
{
    global $dbh;
    if (is_mysql()) {
        $sql_stmts = array("ALTER TABLE maia_users ADD COLUMN truncate_subject int unsigned DEFAULT '20' NOT NULL", "ALTER TABLE maia_users ADD COLUMN truncate_email int unsigned DEFAULT '20' NOT NULL");
    } else {
        $sql_stmts = array("ALTER TABLE maia_users ADD COLUMN truncate_subject INTEGER DEFAULT '20' NOT NULL", "ALTER TABLE maia_users ADD COLUMN truncate_email INTEGER DEFAULT '20' NOT NULL");
    }
    foreach ($sql_stmts as $sql) {
        $result = $dbh->query($sql);
        if (PEAR::isError($result)) {
            $str = $result->getMessage() . " = [" . $sql . "]";
            /* return array(false, $result->getMessage()); */
            return array(false, $str);
        }
    }
    return array(true, "");
}
开发者ID:einheit,项目名称:mailguard_legacy,代码行数:18,代码来源:8.php


示例7: upgrade_4

function upgrade_4()
{
    global $dbh;
    if (is_mysql()) {
        $sql_stmts = array("CREATE TABLE maia_tokens ( " . "id INT UNSIGNED NOT NULL AUTO_INCREMENT, " . "token_system VARCHAR( 32 ) NOT NULL, " . "token CHAR( 32 ) NOT NULL, " . "data BLOB NOT NULL, " . "expires DATETIME NOT NULL, " . "PRIMARY KEY ( id ), " . "UNIQUE token ( token, token_system ), " . "INDEX token_system ( token_system ), " . "INDEX expires (expires) " . ") TYPE=InnoDB", "ALTER TABLE maia_mail_recipients ADD COLUMN token char(32)", "ALTER TABLE maia_users ADD COLUMN quarantine_digest_interval int unsigned DEFAULT '0' NOT NULL", "ALTER TABLE maia_users ADD COLUMN last_digest_sent datetime", "UPDATE maia_mail_recipients set token = MD5(CONCAT(mail_id,'-',recipient_id,'-',RAND()))", "ALTER TABLE maia_mail_recipients CHANGE token token CHAR( 32 ) NOT NULL", "ALTER TABLE maia_mail_recipients ADD CONSTRAINT UNIQUE token_system_idx ( token )");
    } else {
        $sql_stmts = array("CREATE TABLE maia_tokens (\n                        id            SERIAL PRIMARY KEY,\n                        token_system  VARCHAR( 32 ) NOT NULL ,\n                        token         CHAR( 32 ) NOT NULL ,\n                        data          bytea NOT NULL ,\n                        expires       TIMESTAMP NOT NULL\n                        )", "CREATE UNIQUE INDEX token_system_key ON maia_tokens (token,token_system)", "CREATE INDEX token_system ON maia_tokens ( token_system )", "CREATE INDEX expires ON maia_tokens ( expires )", "ALTER TABLE maia_mail_recipients ADD COLUMN token char(32)", "ALTER TABLE maia_users ADD COLUMN quarantine_digest_interval INTEGER DEFAULT '0' NOT NULL", "ALTER TABLE maia_users ALTER quarantine_digest_interval SET DEFAULT '1'", "UPDATE maia_users SET quarantine_digest_interval = '0'", "ALTER TABLE maia_users ALTER quarantine_digest_interval SET NOT NULL", "ALTER TABLE maia_users ADD COLUMN last_digest_sent TIMESTAMP", "UPDATE maia_mail_recipients set token = md5(NOW() || mail_id || '-' || recipient_id || '-' || RANDOM())", "ALTER TABLE maia_mail_recipients ALTER token SET NOT NULL", "CREATE INDEX token_idx ON maia_mail_recipients(token)");
    }
    foreach ($sql_stmts as $sql) {
        $result = $dbh->query($sql);
        if (PEAR::isError($result)) {
            $str = $result->getMessage() . " = [" . $sql . "]";
            /* return array(false, $result->getMessage()); */
            return array(false, $str);
        }
    }
    return array(true, "");
}
开发者ID:einheit,项目名称:mailguard_legacy,代码行数:18,代码来源:4.php


示例8: xmldb_blocktype_externalfeed_upgrade

function xmldb_blocktype_externalfeed_upgrade($oldversion = 0)
{
    if ($oldversion < 2008042101) {
        // We hit the 255 character limit for feed URLs
        if (is_postgres()) {
            execute_sql('ALTER TABLE {blocktype_externalfeed_data} ALTER COLUMN url TYPE TEXT');
        } else {
            if (is_mysql()) {
                // If 2 URLs > 255 chars have the same first 255 characters then mahara will error - this is a MySQL issue though, their unique key length limit is to blame
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} DROP KEY {blocextedata_url_uix}');
                // We have to remove then add the constraint again else the change will make MySQL cry
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} MODIFY COLUMN "url" text');
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} add unique {blocextedata_url_uix} (url(255))');
            }
        }
    }
    if ($oldversion < 2009121600) {
        if (is_mysql()) {
            // Make content column wider (TEXT is only 65kb in mysql)
            $table = new XMLDBTable('blocktype_externalfeed_data');
            $field = new XMLDBField('content');
            $field->setAttributes(XMLDB_TYPE_TEXT, "big", null, null);
            change_field_precision($table, $field);
        }
    }
    if ($oldversion < 2010073000) {
        execute_sql('
            UPDATE {blocktype_cron}
            SET minute = ?
            WHERE minute = ? AND hour = ? AND plugin = ? AND callfunction = ?', array('30', '0', '3', 'externalfeed', 'cleanup_feeds'));
    }
    if ($oldversion < 2011091400) {
        // Add columns for HTTP basic auth
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $field1 = new XMLDBField('authuser');
        $field1->setAttributes(XMLDB_TYPE_TEXT);
        $field2 = new XMLDBField('authpassword');
        $field2->setAttributes(XMLDB_TYPE_TEXT);
        add_field($table, $field1);
        add_field($table, $field2);
        // Change unique constraint that's no longer valid
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $index = new XMLDBIndex('url_uix');
        $index->setAttributes(XMLDB_INDEX_UNIQUE, array('url'));
        drop_index($table, $index);
        if (is_postgres()) {
            $index = new XMLDBIndex('urlautautix');
            $index->setAttributes(XMLDB_INDEX_NOTUNIQUE, array('url', 'authuser', 'authpassword'));
            add_index($table, $index);
        } else {
            if (is_mysql()) {
                // MySQL needs size limits when indexing text fields
                execute_sql('ALTER TABLE {blocktype_externalfeed_data} ADD INDEX
                           {blocextedata_urlautaut_ix} (url(255), authuser(255), authpassword(255))');
            }
        }
    }
    if ($oldversion < 2011091401) {
        // Add columns for insecure SSL mode
        $table = new XMLDBTable('blocktype_externalfeed_data');
        $field = new XMLDBField('insecuresslmode');
        $field->setAttributes(XMLDB_TYPE_INTEGER, 1, null, XMLDB_NOTNULL, null, null, null, 0);
        add_field($table, $field);
    }
    if ($oldversion < 2012090700) {
        // Reset all feeds to reset themselves
        set_field('blocktype_externalfeed_data', 'lastupdate', db_format_timestamp('0'));
        safe_require('blocktype', 'externalfeed');
        call_static_method('PluginBlocktypeExternalfeed', 'refresh_feeds');
    }
    if ($oldversion < 2014041500) {
        log_debug('Cleaning up duplicate feeds in the externalfeed blocktype');
        log_debug('1. Find the duplicate feed urls');
        // Setting these to be empty strings instead of NULL will make our SQL a lot simpler in the next section
        execute_sql("update {blocktype_externalfeed_data} set authuser='' where authuser is null");
        execute_sql("update {blocktype_externalfeed_data} set authpassword='' where authpassword is null");
        if ($duplicatefeeds = get_records_sql_array("SELECT COUNT(url), url, authuser, authpassword FROM {blocktype_externalfeed_data} GROUP BY url, authuser, authpassword HAVING COUNT(url) > 1 ORDER BY url, authuser, authpassword", array())) {
            log_debug('2. Get all feed ids for the duplicated feed urls');
            // Use the 1st one found to be the feed id for the block instances that need updating
            $feedstoupdate = array();
            foreach ($duplicatefeeds as $feed) {
                $feedids = get_column('blocktype_externalfeed_data', 'id', 'url', $feed->url, 'authuser', $feed->authuser, 'authpassword', $feed->authpassword);
                $feedstoupdate[$feed->url] = $feedids;
            }
            log_debug('3. Updating blocks to use correct feed id');
            // Find the block instances using external feeds. Check to see if they are not using the 'true' id and update them accordingly
            require_once get_config('docroot') . 'blocktype/lib.php';
            $blockids = get_records_array('block_instance', 'blocktype', 'externalfeed', 'id ASC', 'id');
            foreach ($blockids as $blockid) {
                $blockinstance = new BlockInstance($blockid->id);
                $configdata = $blockinstance->get('configdata');
                if (!empty($configdata['feedid'])) {
                    foreach ($feedstoupdate as $url => $ids) {
                        foreach ($ids as $key => $id) {
                            if ($id == $configdata['feedid'] && $key != '0') {
                                $configdata['feedid'] = $ids[0];
                                $blockinstance->set('configdata', $configdata);
                                $blockinstance->set('dirty', true);
                                $blockinstance->commit();
                                break;
//.........这里部分代码省略.........
开发者ID:janaece,项目名称:globalclassroom4_clean,代码行数:101,代码来源:upgrade.php


示例9: search_view_owners

 /**
  * Search view owners.
  */
 public static function search_view_owners($query = null, $template = null, $limit = null, $offset = 0)
 {
     if ($template) {
         $tsql = ' AND v.template = 1';
     } else {
         if ($template === false) {
             $tsql = ' AND v.template = 0';
         } else {
             $tsql = '';
         }
     }
     if ($query) {
         $ph = array($query);
         $qsql = ' WHERE display ' . db_ilike() . " '%' || ? || '%' ";
     } else {
         $ph = array();
         $qsql = '';
     }
     if (is_mysql()) {
         $uid = 'u.id';
         $gid = 'g.id';
     } else {
         $uid = 'CAST (u.id AS TEXT)';
         $gid = 'CAST (g.id AS TEXT)';
     }
     $sql = "\n                SELECT\n                    'user' AS ownertype,\n                    CASE WHEN u.preferredname IS NULL OR u.preferredname = '' THEN u.firstname || ' ' || u.lastname\n                    ELSE u.preferredname END AS display,\n                    {$uid}, COUNT(v.id)\n                FROM {usr} u INNER JOIN {view} v ON (v.owner = u.id AND v.type = 'portfolio')\n                WHERE u.deleted = 0 {$tsql}\n                GROUP BY ownertype, display, u.id\n            UNION\n                SELECT 'group' AS ownertype, g.name AS display, {$gid}, COUNT(v.id)\n                FROM {group} g INNER JOIN {view} v ON (g.id = v.group)\n                WHERE g.deleted = 0 {$tsql}\n                GROUP BY ownertype, display, g.id\n            UNION\n                SELECT 'institution' AS ownertype, i.displayname AS display, i.name AS id, COUNT(v.id)\n                FROM {institution} i INNER JOIN {view} v ON (i.name = v.institution)\n                WHERE TRUE {$tsql}\n                GROUP BY ownertype, display, i.name ORDER BY display";
     $count = count_records_sql("SELECT COUNT(*) FROM ({$sql}) q {$qsql}", $ph);
     $data = get_records_sql_array("SELECT * FROM ({$sql}) q {$qsql} ORDER BY ownertype != 'institution', id != 'mahara', ownertype", $ph, $offset, $limit);
     foreach ($data as &$r) {
         if ($r->ownertype == 'institution' && $r->id == 'mahara') {
             $r->display = get_config('sitename');
         }
     }
     return array('data' => array_values($data), 'count' => $count, 'limit' => $limit, 'offset' => $offset);
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:38,代码来源:view.php


示例10: core_install_lastcoredata_defaults

function core_install_lastcoredata_defaults()
{
    db_begin();
    $institution = new StdClass();
    $institution->name = 'mahara';
    $institution->displayname = 'No Institution';
    $institution->authplugin = 'internal';
    $institution->theme = 'default';
    insert_record('institution', $institution);
    $auth_instance = new StdClass();
    $auth_instance->instancename = 'Internal';
    $auth_instance->priority = '1';
    $auth_instance->institution = 'mahara';
    $auth_instance->authname = 'internal';
    $auth_instance->id = insert_record('auth_instance', $auth_instance, 'id', true);
    // Insert the root user
    $user = new StdClass();
    $user->id = 0;
    $user->username = 'root';
    $user->password = '*';
    $user->salt = '*';
    $user->firstname = 'System';
    $user->lastname = 'User';
    $user->email = '[email protected]';
    $user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
    $user->authinstance = $auth_instance->id;
    if (is_mysql()) {
        // gratuitous mysql workaround
        $newid = insert_record('usr', $user, 'id', true);
        set_field('usr', 'id', 0, 'id', $newid);
        execute_sql('ALTER TABLE {usr} AUTO_INCREMENT=1');
    } else {
        insert_record('usr', $user);
    }
    install_system_profile_view();
    // Insert the admin user
    $user = new StdClass();
    $user->username = 'admin';
    $user->password = 'mahara';
    $user->authinstance = $auth_instance->id;
    $user->passwordchange = 1;
    $user->admin = 1;
    $user->firstname = 'Admin';
    $user->lastname = 'User';
    $user->email = '[email protected]';
    $user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
    $user->id = insert_record('usr', $user, 'id', true);
    set_profile_field($user->id, 'email', $user->email);
    set_profile_field($user->id, 'firstname', $user->firstname);
    set_profile_field($user->id, 'lastname', $user->lastname);
    set_config('installed', true);
    handle_event('createuser', $user->id);
    activity_add_admin_defaults(array($user->id));
    db_commit();
    // if we're installing, set up the block categories here and then poll the plugins.
    // if we're upgrading this happens somewhere else.  This is because of dependency issues around
    // the order of installation stuff.
    install_blocktype_extras();
}
开发者ID:Br3nda,项目名称:mahara,代码行数:59,代码来源:upgrade.php


示例11: upgrade_11

function upgrade_11()
{
    global $dbh;
    if (is_mysql()) {
        $sql_stmts = array("ALTER TABLE maia_domains\n                     ADD routing_domain VARCHAR(255) DEFAULT '' NOT NULL,\n                     ADD transport VARCHAR(255) DEFAULT ':' NOT NULL", "ALTER TABLE maia_domains ADD INDEX maia_domains_idx_routing_domain(routing_domain)", "UPDATE maia_domains set routing_domain = substring(domain, 2)", "UPDATE maia_domains set routing_domain='*' where domain='@.'");
    } else {
        $sql_stmts = array("ALTER TABLE maia_domains ADD COLUMN routing_domain VARCHAR(255) NOT NULL DEFAULT ''", "ALTER TABLE maia_domains ADD COLUMN transport VARCHAR(255) NOT NULL DEFAULT ':'", "CREATE INDEX maia_domains_idx_routing_domain ON maia_domains(routing_domain)", "UPDATE maia_domains SET routing_domain = substring(domain from 2)", "UPDATE maia_domains set routing_domain='*' where domain='@.'");
    }
    foreach ($sql_stmts as $sql) {
        $result = $dbh->query($sql);
        if (PEAR::isError($result)) {
            $str = $result->getMessage() . " = [" . $sql . "]";
            /* return array(false, $result->getMessage()); */
            return array(false, $str);
        }
    }
    return array(true, "");
}
开发者ID:einheit,项目名称:mailguard_legacy,代码行数:18,代码来源:11.php


示例12: get_active_topics

 public static function get_active_topics($limit, $offset, $category, $forumids = array())
 {
     global $USER;
     if (is_postgres()) {
         $lastposts = '
                 SELECT DISTINCT ON (topic) topic, id, poster, subject, body, ctime
                 FROM {interaction_forum_post} p
                 WHERE p.deleted = 0
                 ORDER BY topic, ctime DESC';
     } else {
         if (is_mysql()) {
             $lastposts = '
                 SELECT topic, id, poster, subject, body, ctime
                 FROM (
                     SELECT topic, id, poster, subject, body, ctime
                     FROM {interaction_forum_post}
                     WHERE deleted = 0
                     ORDER BY ctime DESC
                 ) temp1
                 GROUP BY topic';
         }
     }
     $values = array();
     $from = '
         FROM
             {interaction_forum_topic} t
             JOIN {interaction_instance} f ON t.forum = f.id
             JOIN {group} g ON f.group = g.id';
     // user is not anonymous
     if ($USER->get('id') > 0) {
         $from .= '
             JOIN {group_member} gm ON (gm.group = g.id AND gm.member = ?)
         ';
         $values[] = $USER->get('id');
     }
     $from .= '
             JOIN {interaction_forum_post} first ON (first.topic = t.id AND first.parent IS NULL)
             JOIN (' . $lastposts . '
             ) last ON last.topic = t.id';
     $where = '
         WHERE g.deleted = 0 AND f.deleted = 0 AND t.deleted = 0';
     if (!empty($category)) {
         $where .= ' AND g.category = ?';
         $values[] = (int) $category;
     }
     if (!empty($forumids)) {
         $where .= ' AND f.id IN (' . join(',', array_fill(0, count($forumids), '?')) . ')';
         $values = array_merge($values, $forumids);
     }
     $result = array('count' => count_records_sql('SELECT COUNT(*) ' . $from . $where, $values), 'limit' => $limit, 'offset' => $offset, 'data' => array());
     if (!$result['count']) {
         return $result;
     }
     $select = '
         SELECT
             t.id, t.forum AS forumid, f.title AS forumname, g.id AS groupid, g.name AS groupname, g.urlid,
             first.subject AS topicname, first.poster AS firstpostby,
             last.id AS postid, last.poster, last.subject, last.body, last.ctime, edits.ctime as mtime,
             COUNT(posts.id) AS postcount';
     $from .= '
             LEFT JOIN {interaction_forum_post} posts ON posts.topic = t.id
             LEFT JOIN {interaction_forum_edit} edits ON edits.post = last.id';
     $sort = '
         GROUP BY
             t.id, t.forum, f.title, g.id, g.name, g.urlid,
             first.subject, first.poster,
             last.id, last.poster, last.subject, last.body, last.ctime, edits.ctime
         ORDER BY last.ctime DESC';
     $result['data'] = get_records_sql_array($select . $from . $where . $sort, $values, $offset, $limit);
     foreach ($result['data'] as &$r) {
         $r->groupurl = group_homepage_url((object) array('id' => $r->groupid, 'urlid' => $r->urlid));
     }
     return $result;
 }
开发者ID:vohung96,项目名称:mahara,代码行数:74,代码来源:lib.php


示例13: get_comments

 /**
  * Generates the data object required for displaying comments on the page.
  *
  * @param   object  $options  Object of comment options
  *                            - defaults can be retrieved from get_comment_options()
  * @return  object $result    Comment data object
  */
 public static function get_comments($options)
 {
     global $USER;
     $allowedoptions = self::get_comment_options();
     // set the object's key/val pairs as variables
     foreach ($options as $key => $option) {
         if (array_key_exists($key, $allowedoptions)) {
         }
         ${$key} = $option;
     }
     $userid = $USER->get('id');
     $viewid = $view->get('id');
     if (!empty($artefact)) {
         $canedit = $USER->can_edit_artefact($artefact);
         $owner = $artefact->get('owner');
         $isowner = $userid && $userid == $owner;
         $artefactid = $artefact->get('id');
     } else {
         $canedit = $USER->can_moderate_view($view);
         $owner = $view->get('owner');
         $isowner = $userid && $userid == $owner;
         $artefactid = null;
     }
     // Find out whether the page's owner has threaded comments or not
     if ($owner) {
         $threaded = get_user_institution_comment_threads($owner);
     } else {
         $threaded = false;
     }
     $result = (object) array('limit' => $limit, 'offset' => $offset, 'view' => $viewid, 'artefact' => $artefactid, 'canedit' => $canedit, 'owner' => $owner, 'isowner' => $isowner, 'export' => $export, 'sort' => $sort, 'threaded' => $threaded, 'data' => array());
     if (!empty($artefactid)) {
         $where = 'c.onartefact = ' . (int) $artefactid;
     } else {
         $where = 'c.onview = ' . (int) $viewid;
     }
     if (!$canedit) {
         $where .= ' AND (';
         $where .= 'c.private = 0 ';
         // Comment is public
         $where .= 'OR a.author = ' . (int) $userid;
         // You are the comment author
         if ($threaded) {
             $where .= ' OR p.author = ' . (int) $userid;
             // you authored the parent
         }
         $where .= ')';
     }
     $result->count = count_records_sql('
         SELECT COUNT(*)
         FROM
             {artefact} a
             JOIN {artefact_comment_comment} c
                 ON a.id = c.artefact
             LEFT JOIN {artefact} p
                 ON a.parent = p.id
         WHERE ' . $where);
     if ($result->count > 0) {
         // Figure out sortorder
         if (!$threaded) {
             $orderby = 'a.ctime ' . ($sort == 'latest' ? 'DESC' : 'ASC');
         } else {
             if ($sort != 'latest') {
                 // Threaded ascending
                 $orderby = 'a.path ASC, a.ctime ASC, a.id';
             } else {
                 // Threaded & descending. Sort "root comments" by descending order, and the
                 // comments below them in ascending order. (This is the only sane way to do it.)
                 if (is_mysql()) {
                     $splitfunc = 'SUBSTRING_INDEX';
                 } else {
                     $splitfunc = 'SPLIT_PART';
                 }
                 $orderby = "{$splitfunc}(a.path, '/', 2) DESC, a.path ASC, a.ctime ASC, a.id";
             }
         }
         // If pagination is in use, see if we want to get a page with particular comment
         if ($limit) {
             if ($showcomment == 'last') {
                 // If we have limit (pagination is used) ignore $offset and just get the last page of feedback.
                 $result->forceoffset = $offset = (ceil($result->count / $limit) - 1) * $limit;
             } else {
                 if (is_numeric($showcomment)) {
                     // Ignore $offset and get the page that has the comment
                     // with id $showcomment on it.
                     // Fetch everything and figure out which page $showcomment is in.
                     // This will get ugly if there are 1000s of comments
                     $ids = get_column_sql('
                         SELECT a.id
                         FROM {artefact} a JOIN {artefact_comment_comment} c ON a.id = c.artefact
                             LEFT JOIN {artefact} p ON a.parent = p.id
                         WHERE ' . $where . '
                         ORDER BY ' . $orderby, array());
                     $found = false;
//.........这里部分代码省略.........
开发者ID:kienv,项目名称:mahara,代码行数:101,代码来源:lib.php


示例14: ConfigSanityException

        $db->port = $CFG->dbport;
    }
    if (!empty($CFG->dbpersist)) {
        // Use persistent connection (default)
        $dbconnected = $db->PConnect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname);
    } else {
        // Use single connection
        $dbconnected = $db->Connect($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname);
    }
    // Now we have a connection, verify the server is a new enough version
    $dbversion = $db->ServerInfo();
    if (is_postgres()) {
        $okversion = '8.3';
        $dbfriendlyname = 'PostgreSQL';
    } else {
        if (is_mysql()) {
            $okversion = '5.0.25';
            $dbfriendlyname = 'MySQL';
        }
    }
    if (floatval($dbversion['version']) < floatval($okversion)) {
        throw new ConfigSanityException(get_string('dbversioncheckfailed', 'error', $dbfriendlyname, $dbversion['version'], $okversion));
    }
    $db->SetFetchMode(ADODB_FETCH_ASSOC);
    configure_dbconnection();
    ensure_internal_plugins_exist();
    ob_end_clean();
} catch (Exception $e) {
    if ($e instanceof ConfigSanityException) {
        throw $e;
    }
开发者ID:rboyatt,项目名称:mahara,代码行数:31,代码来源:init.php


示例15: core_install_lastcoredata_defaults

function core_install_lastcoredata_defaults()
{
    global $USER;
    db_begin();
    $institution = new StdClass();
    $institution->name = 'mahara';
    $institution->displayname = 'No Institution';
    $institution->authplugin = 'internal';
    $institution->theme = 'default';
    $institution->priority = 0;
    insert_record('institution', $institution);
    $pages = site_content_pages();
    $now = db_format_timestamp(time());
    foreach ($pages as $name) {
        $page = new stdClass();
        $page->name = $name;
        $page->ctime = $now;
        $page->mtime = $now;
        $page->content = get_string($page->name . 'defaultcontent', 'install', get_string('staticpageconfigdefault', 'install'));
        $page->institution = 'mahara';
        insert_record('site_content', $page);
    }
    $auth_instance = new StdClass();
    $auth_instance->instancename = 'Internal';
    $auth_instance->priority = '1';
    $auth_instance->institution = 'mahara';
    $auth_instance->authname = 'internal';
    $auth_instance->id = insert_record('auth_instance', $auth_instance, 'id', true);
    // Insert the root user
    $user = new StdClass();
    $user->id = 0;
    $user->username = 'root';
    $user->password = '*';
    $user->salt = '*';
    $user->firstname = 'System';
    $user->lastname = 'User';
    $user->email = '[email protected]';
    $user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
    $user->authinstance = $auth_instance->id;
    if (is_mysql()) {
        // gratuitous mysql workaround
        $newid = insert_record('usr', $user, 'id', true);
        set_field('usr', 'id', 0, 'id', $newid);
        execute_sql('ALTER TABLE {usr} AUTO_INCREMENT=1');
    } else {
        insert_record('usr', $user);
    }
    // install the default layout options
    install_view_layout_defaults();
    require_once 'group.php';
    install_system_profile_view();
    install_system_dashboard_view();
    install_system_grouphomepage_view();
    require_once 'license.php';
    install_licenses_default();
    require_once 'skin.php';
    install_skins_default();
    // Insert the admin user
    $user = new StdClass();
    $user->username = 'admin';
    $user->salt = auth_get_random_salt();
    $user->password = crypt('mahara', '$2a$' . get_config('bcrypt_cost') . '$' . substr(md5(get_config('passwordsaltmain') . $user->salt), 0, 22));
    $user->password = substr($user->password, 0, 7) . substr($user->password, 7 + 22);
    $user->authinstance = $auth_instance->id;
    $user->passwordchange = 1;
    $user->admin = 1;
    $user->firstname = 'Admin';
    $user->lastname = 'User';
    $user->email = '[email protected]';
    $user->quota = get_config_plugin('artefact', 'file', 'defaultquota');
    $user->id = insert_record('usr', $user, 'id', true);
    set_profile_field($user->id, 'email', $user->email);
    set_profile_field($user->id, 'firstname', $user->firstname);
    set_profile_field($user->id, 'lastname', $user->lastname);
    handle_event('createuser', $user);
    activity_add_admin_defaults(array($user->id));
    db_commit();
    // if we're installing, set up the block categories here and then poll the plugins.
    // if we're upgrading this happens somewhere else.  This is because of dependency issues around
    // the order of installation stuff.
    install_blocktype_extras();
}
开发者ID:agwells,项目名称:Mahara-1,代码行数:82,代码来源:upgrade.php


示例16: get_post_data

 /**
  * This function returns the blog id and offset for a given post.
  *
  * @param integer $postid The id of the required blog post
  * @return object An object containing the required data
  */
 public static function get_post_data($postid)
 {
     $post = new stdClass();
     $post->blogid = get_field('artefact', 'parent', 'id', $postid, 'artefacttype', 'blogpost');
     if (is_postgres()) {
         $rownum = get_field_sql("SELECT rownum\n                                    FROM (SELECT id, ROW_NUMBER() OVER (ORDER BY id DESC) AS rownum\n                                        FROM {artefact}\n                                        WHERE parent = ?\n                                        ORDER BY id DESC) AS posts\n                                    WHERE id = ?", array($post->blogid, $postid));
     } else {
         if (is_mysql()) {
             $initvar = execute_sql("SET @row_num = 0");
             if ($initvar) {
                 $rownum = get_field_sql("SELECT rownum\n                                        FROM (SELECT id, @row_num := @row_num + 1 AS rownum\n                                            FROM {artefact}\n                                            WHERE parent = ?\n                                            ORDER BY id DESC) AS posts\n                                        WHERE id = ?", array($post->blogid, $postid));
             }
         }
     }
     $post->offset = $rownum - 1;
     return $post;
 }
开发者ID:sarahjcotton,项目名称:mahara,代码行数:23,代码来源:lib.php


示例17: xmldb_artefact_resume_upgrade

function xmldb_artefact_resume_upgrade($oldversion = 0)
{
    $status = true;
    if ($oldversion < 2008012200) {
        if (is_mysql()) {
            $inttype = 'BIGINT(10)';
        } else {
            $inttype = 'INTEGER';
        }
        foreach (array('artefact_resume_employmenthistory', 'artefact_resume_educationhistory', 'artefact_resume_membership') as $table) {
            $records = get_records_array($table, '', '', 'startdate DESC', 'id,startdate,enddate');
            // Sigh. table_column is screwed beyond belief. We let it do its
            // work (in the case of start and stopdate at least because it does
            // cast the columns OK), then fix its bugs
            execute_sql('ALTER TABLE {' . $table . '} ADD displayorder ' . $inttype);
            table_column($table, 'startdate', 'startdate', 'text', null, null, '', 'not null');
            table_column($table, 'enddate', 'enddate', 'text', null, null, '', '');
            // MySQL docs say:
            //  * BLOB and TEXT columns cannot have DEFAULT values.
            // It turns out they do - a default of ''. And dropping this results in:
            // mysql> ALTER TABLE "artefact_resume_employmenthistory" ALTER COLUMN startdate DROP DEFAULT;
            // ERROR 1101 (42000): BLOB/TEXT column 'startdate' can't have a default value
            //
            if (is_postgres()) {
                execute_sql('ALTER TABLE {' . $table . '} ALTER COLUMN startdate DROP DEFAULT');
                execute_sql('ALTER TABLE {' . $table . '} ALTER COLUMN enddate DROP DEFAULT');
            }
            if (!empty($record 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP is_nan函数代码示例发布时间:2022-05-15
下一篇:
PHP is_my_shared_folder函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap