当前位置: 首页>>代码示例>>PHP>>正文


PHP DBUtil::executeSQL方法代码示例

本文整理汇总了PHP中DBUtil::executeSQL方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::executeSQL方法的具体用法?PHP DBUtil::executeSQL怎么用?PHP DBUtil::executeSQL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DBUtil的用法示例。


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

示例1: EZComments_migrateapi_pnFlashGames

/**
 * Do the migration
 * 
 * With this function, the actual migration is done.
 * 
 * @return   boolean   true on sucessful migration, false else
 * @since    0.2
 */
function EZComments_migrateapi_pnFlashGames()
{
    // Security check
    if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerError('pnFlashGames comments migration: Not Admin');
    }
    // Get datbase setup
    $tables = DBUtil::getTables();
    $Commentstable = $tables['pnFlashGames_comments'];
    $Commentscolumn = $tables['pnFlashGames_comments_column'];
    $Usertable = $tables['users'];
    $Usercolumn = $tables['users_column'];
    $sql = "SELECT {$Commentscolumn['gid']},\n                   {$Commentscolumn['uname']},\n                   {$Commentscolumn['date']},\n                   {$Commentscolumn['comment']},\n                   {$Usercolumn['uid']}\n             FROM  {$Commentstable}\n         LEFT JOIN {$Usertable}\n                ON {$Commentscolumn['uname']} = {$Usercolumn['uname']}";
    $result = DBUtil::executeSQL($sql);
    if ($result == false) {
        return LogUtil::registerError('pnFlashGames migration: DB Error: ' . $sql . ' -- ' . mysql_error());
    }
    // loop through the old comments and insert them one by one into the DB
    $items = DBUtil::marshalObjects($result, array('gid', 'uname', 'date', 'comment', 'uid'));
    foreach ($items as $item) {
        // set the correct user id for anonymous users
        if (empty($item['uid'])) {
            $item['uid'] = 1;
        }
        $id = ModUtil::apiFunc('EZComments', 'user', 'create', array('mod' => 'pnFlashGames', 'objectid' => DataUtil::formatForStore($item['gid']), 'url' => ModUtil::url('pnFlashGames', 'user', 'display', array('id' => $item['gid'])), 'comment' => $item['comment'], 'subject' => '', 'uid' => $item['uid'], 'date' => $item['date']));
        if (!$id) {
            return LogUtil::registerError('pnFlashGames migration: Error creating comment');
        }
    }
    return LogUtil::registerStatus('pnFlashGames migration successful');
}
开发者ID:rmaiwald,项目名称:EZComments,代码行数:39,代码来源:pnFlashGames.php

示例2: upgrade

    /**
     * Update the IWwebbox module
     * @author Albert Pérez Monfort (aperezm@xtec.cat)
     * @author Jaume Fernàndez Valiente (jfern343@xtec.cat)
     * @return bool true if successful, false otherwise
     */
    public function upgrade($oldversion) {

        // Update z_blocs table

        $c = "UPDATE blocks SET bkey = 'Webbox' WHERE bkey = 'webbox'";
        if (!DBUtil::executeSQL($c)) {
            return false;
        }

        //Array de noms
        $oldVarsNames = DBUtil::selectFieldArray("module_vars", 'name', "`modname` = 'IWwebbox'", '', false, '');

        $newVarsNames = Array('url', 'width', 'height', 'scrolls', 'widthunit');

        $newVars = Array('url' => 'http://phobos.xtec.cat/intraweb',
            'width' => '100',
            'height' => '600',
            'scrolls' => '1',
            'widthunit' => '%');    

        // Delete unneeded vars
        $del = array_diff($oldVarsNames, $newVarsNames);
        foreach ($del as $i) {
            $this->delVar($i);
        }

        // Add new vars
        $add = array_diff($newVarsNames, $oldVarsNames);
        foreach ($add as $i) {
            $this->setVar($i, $newVars[$i]);
        }

        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:40,代码来源:Installer.php

示例3: upgrade

 /**
  * upgrade the module from an old version
  *
  * This function must consider all the released versions of the module!
  * If the upgrade fails at some point, it returns the last upgraded version.
  *
  * @param        string   $oldVersion   version number string to upgrade from
  * @return       mixed    true on success, last valid version string or false if fails
  */
 public function upgrade($oldversion)
 {
     // Upgrade dependent on old version number
     switch ($oldversion) {
         case '3.6':
             // Rename 'thelang' block.
             $table = 'blocks';
             $sql = "UPDATE {$table} SET bkey = 'lang' WHERE bkey = 'thelang'";
             \DBUtil::executeSQL($sql);
             // Optional upgrade
             if (in_array(\DBUtil::getLimitedTablename('message'), \DBUtil::metaTables())) {
                 $this->migrateMessages();
             }
             $this->migrateBlockNames();
             $this->migrateExtMenu();
         case '3.7':
         case '3.7.0':
             if (!\DBUtil::changeTable('blocks')) {
                 return false;
             }
         case '3.7.1':
             $this->newBlockPositions();
         case '3.8.0':
             // update empty filter fields to an empty array
             $entity = $this->name . '\\Entity\\Block';
             $dql = "UPDATE {$entity} p SET p.filter = 'a:0:{}' WHERE p.filter = '' OR p.filter = 's:0:\"\";'";
             $query = $this->entityManager->createQuery($dql);
             $query->getResult();
         case '3.8.1':
             // future upgrade routines
     }
     // Update successful
     return true;
 }
开发者ID:planetenkiller,项目名称:core,代码行数:43,代码来源:Installer.php

示例4: mediashare_mediahandlerapi_getHandlerInfo

function mediashare_mediahandlerapi_getHandlerInfo($args)
{
    $dom = ZLanguage::getModuleDomain('mediashare');
    $mimeType = strtolower($args['mimeType']);
    $filename = strtolower($args['filename']);
    if (!empty($filename)) {
        $dotPos = strpos($filename, '.');
        if ($dotPos === false) {
            $fileType = '';
        } else {
            $fileType = substr($filename, $dotPos + 1);
        }
    } else {
        $fileType = '';
    }
    $pntable = pnDBGetTables();
    $handlersTable = $pntable['mediashare_mediahandlers'];
    $handlersColumn = $pntable['mediashare_mediahandlers_column'];
    $sql = "SELECT DISTINCT {$handlersColumn['handler']},\r\n                            {$handlersColumn['foundMimeType']},\r\n                            {$handlersColumn['foundFileType']}\r\n                       FROM {$handlersTable}\r\n                      WHERE {$handlersColumn['mimeType']} = '" . DataUtil::formatForStore($mimeType) . "'\r\n                         OR {$handlersColumn['fileType']} = '" . DataUtil::formatForStore($fileType) . "'\r\n\t\t\t\t\t\t\t\t\t\t\t\tAND {$handlersColumn['active']} =\t1 ";
    $result = DBUtil::executeSQL($sql);
    $errormsg = __f('Unable to locate media handler for \'%1$s\' (%2$s)', array($filename, $mimeType), $dom);
    if ($result === false) {
        return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('mediahandlerapi.getHandlerInfo', $errormsg), $dom));
    }
    if (!$result) {
        return LogUtil::registerError($errormsg);
    }
    $colArray = array('handlerName', 'mimeType', 'fileType');
    $handler = DBUtil::marshallObjects($result, $colArray);
    return $handler[0];
}
开发者ID:ro0f,项目名称:Mediashare,代码行数:31,代码来源:pnmediahandlerapi.php

示例5: delete

 function delete()
 {
     // security check
     if (!SecurityUtil::checkPermission('AddressBook::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError();
     }
     $ot = FormUtil::getPassedValue('ot', 'categories', 'GETPOST');
     $id = (int) FormUtil::getPassedValue('id', 0, 'GETPOST');
     $url = ModUtil::url('AddressBook', 'admin', 'view', array('ot' => $ot));
     $class = 'AddressBook_DBObject_' . ucfirst($ot);
     if (!class_exists($class)) {
         return z_exit(__f('Error! Unable to load class [%s]', $ot));
     }
     $object = new $class();
     $data = $object->get($id);
     if (!$data) {
         LogUtil::registerError(__f('%1$s with ID of %2$s doesn\'\\t seem to exist', array($ot, $id)));
         return System::redirect($url);
     }
     $object->delete();
     if ($ot == "customfield") {
         $sql = "ALTER TABLE addressbook_address DROP adr_custom_" . $id;
         try {
             DBUtil::executeSQL($sql, -1, -1, true, true);
         } catch (Exception $e) {
         }
     }
     LogUtil::registerStatus($this->__('Done! Item deleted.'));
     return System::redirect($url);
 }
开发者ID:nmpetkov,项目名称:AddressBook,代码行数:30,代码来源:Admin.php

示例6: search

 /**
  * Search
  *
  * do the actual search and display the results
  *
  * @return output the search results
  */
 public function search($args)
 {
     if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_READ)) {
         return true;
     }
     $minlen = 3;
     $maxlen = 30;
     if (strlen($args['q']) < $minlen || strlen($args['q']) > $maxlen) {
         return LogUtil::registerStatus($this->__f('The comments can only be searched for words that are longer than %1$s and less than %2$s characters!', array($minlen, $maxlen)));
     }
     ModUtil::dbInfoLoad('Search');
     $tables = DBUtil::getTables();
     // ezcomments tables
     $ezcommentstable = $tables['EZComments'];
     $ezcommentscolumn = $tables['EZComments_column'];
     // our own tables
     $searchTable = $tables['search_result'];
     $searchColumn = $tables['search_result_column'];
     // where
     $where = Search_Api_User::construct_where($args, array($ezcommentscolumn['subject'], $ezcommentscolumn['comment']));
     $where .= " AND " . $ezcommentscolumn['url'] . " != ''";
     $sessionId = session_id();
     $insertSql = "INSERT INTO {$searchTable}\n              ({$searchColumn['title']},\n               {$searchColumn['text']},\n               {$searchColumn['extra']},\n               {$searchColumn['module']},\n               {$searchColumn['created']},\n               {$searchColumn['session']})\n            VALUES\n            ";
     $comments = DBUtil::selectObjectArray('EZComments', $where);
     foreach ($comments as $comment) {
         $sql = $insertSql . '(' . '\'' . DataUtil::formatForStore($comment['subject']) . '\', ' . '\'' . DataUtil::formatForStore($comment['comment']) . '\', ' . '\'' . DataUtil::formatForStore($comment['url']) . '\', ' . '\'' . 'EZComments' . '\', ' . '\'' . DataUtil::formatForStore($comment['date']) . '\', ' . '\'' . DataUtil::formatForStore($sessionId) . '\')';
         $insertResult = DBUtil::executeSQL($sql);
         if (!$insertResult) {
             return LogUtil::registerError($this->__('Error! Could not load items.'));
         }
     }
     return true;
 }
开发者ID:rmaiwald,项目名称:EZComments,代码行数:40,代码来源:Search.php

示例7: search

 /**
  * Performs the actual search processing.
  */
 public function search($args)
 {
     ModUtil::dbInfoLoad('Search');
     $dbtables = DBUtil::getTables();
     $pageTable = $dbtables['content_page'];
     $pageColumn = $dbtables['content_page_column'];
     $contentTable = $dbtables['content_content'];
     $contentColumn = $dbtables['content_content_column'];
     $contentSearchTable = $dbtables['content_searchable'];
     $contentSearchColumn = $dbtables['content_searchable_column'];
     $translatedPageTable = $dbtables['content_translatedpage'];
     $translatedPageColumn = $dbtables['content_translatedpage_column'];
     $sessionId = session_id();
     // check whether we need to search also in translated content
     $multilingual = System::getVar('multilingual');
     $currentLanguage = ZLanguage::getLanguageCode();
     $searchWhereClauses = array();
     $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($pageColumn['title']), $pageColumn['language']) . ')';
     if ($multilingual) {
         $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($translatedPageColumn['title']), $translatedPageColumn['language']) . ')';
     }
     $searchWhereClauses[] = '(' . Search_Api_User::construct_where($args, array($contentSearchColumn['text']), $contentSearchColumn['language']) . ')';
     // add default filters
     $whereClauses = array();
     $whereClauses[] = '(' . implode(' OR ', $searchWhereClauses) . ')';
     $whereClauses[] = $pageColumn['active'] . ' = 1';
     $whereClauses[] = "({$pageColumn['activeFrom']} IS NULL OR {$pageColumn['activeFrom']} <= NOW())";
     $whereClauses[] = "({$pageColumn['activeTo']} IS NULL OR {$pageColumn['activeTo']} >= NOW())";
     $whereClauses[] = $contentColumn['active'] . ' = 1';
     $whereClauses[] = $contentColumn['visiblefor'] . (UserUtil::isLoggedIn() ? ' <= 1' : ' >= 1');
     $titleFields = $pageColumn['title'];
     $additionalJoins = '';
     if ($multilingual) {
         // if searching in non-default languages, we need the translated title
         $titleFields .= ', ' . $translatedPageColumn['title'] . ' AS translatedTitle';
         // join also the translation table if required
         $additionalJoins = "LEFT OUTER JOIN {$translatedPageTable} ON {$translatedPageColumn['pageId']} = {$pageColumn['id']} AND {$translatedPageColumn['language']} = '{$currentLanguage}'";
         // prevent content snippets in other languages
         $whereClauses[] = $contentSearchColumn['language'] . ' = \'' . $currentLanguage . '\'';
     }
     $where = implode(' AND ', $whereClauses);
     $sql = "\n            SELECT DISTINCT {$titleFields},\n            {$contentSearchColumn['text']} AS description,\n            {$pageColumn['id']} AS pageId,\n            {$pageColumn['cr_date']} AS createdDate\n            FROM {$pageTable}\n            JOIN {$contentTable}\n            ON {$contentColumn['pageId']} = {$pageColumn['id']}\n            JOIN {$contentSearchTable}\n            ON {$contentSearchColumn['contentId']} = {$contentColumn['id']}\n            {$additionalJoins}\n            WHERE {$where}\n        ";
     $result = DBUtil::executeSQL($sql);
     if (!$result) {
         return LogUtil::registerError($this->__('Error! Could not load items.'));
     }
     $objectArray = DBUtil::marshallObjects($result);
     foreach ($objectArray as $object) {
         $pageTitle = $object['page_title'];
         if ($object['translatedTitle'] != '') {
             $pageTitle = $object['translatedTitle'];
         }
         $searchItemData = array('title' => $pageTitle, 'text' => $object['description'], 'extra' => $object['pageId'], 'created' => $object['createdDate'], 'module' => 'Content', 'session' => $sessionId);
         if (!\DBUtil::insertObject($searchItemData, 'search_result')) {
             return \LogUtil::registerError($this->__('Error! Could not save the search results.'));
         }
     }
     return true;
 }
开发者ID:robbrandt,项目名称:Content,代码行数:62,代码来源:Search.php

示例8: getContent

 public function getContent()
 {
     ModUtil::dbInfoLoad('Content');
     $dbtables = DBUtil::getTables();
     $query = "SELECT " . $dbtables['content_page_column']['id'] . " , " . $dbtables['content_page_column']['title'] . ", " . $dbtables['content_page_column']['views'] . " \n    \tFROM " . $dbtables['content_page'] . "\n\tWHERE " . $dbtables['content_page_column']['views'] . " >= 0 AND " . $dbtables['content_page_column']['active'] . " >= 0 ORDER BY " . $dbtables['content_page_column']['views'] . " DESC LIMIT 25";
     $dbresult = DBUtil::executeSQL($query);
     $views = DBUtil::marshallObjects($dbresult);
     $view = Zikula_View::getInstance('Content');
     $view->assign('views', $views);
     return $view->fetch('content_widget_top25.tpl');
 }
开发者ID:robbrandt,项目名称:Dashboard,代码行数:11,代码来源:Top25.php

示例9: EZComments_migrateapi_news

/**
 * Do the migration
 * 
 * With this function, the actual migration is done.
 * 
 * @return   boolean   true on sucessful migration, false else
 * @since    0.2
 */
function EZComments_migrateapi_news()
{
    // Security check
    if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerError('News migration: Not Admin');
    }
    // Get datbase setup
    $tables = DBUtil::getTables();
    $EZCommentstable = $tables['EZComments'];
    $EZCommentscolumn = $tables['EZComments_column'];
    $Commentstable = $tables['comments'];
    $Commentscolumn = $tables['comments_column'];
    if (version_compare(PN_VERSION_NUM, '1', '>=')) {
        EZComments_get76xcolumns_news($Commentstable, $Commentscolumn);
    }
    if (is_null($Commentstable) || is_null($Commentscolumn)) {
        return LogUtil::registerError('News migration: Comments tables not found');
    }
    $Usertable = $tables['users'];
    $Usercolumn = $tables['users_column'];
    $sql = "SELECT {$Commentscolumn['tid']},\n                   {$Commentscolumn['sid']},\n                   {$Commentscolumn['date']}, \n                   {$Usercolumn['uid']},\n                   {$Commentscolumn['comment']},\n                   {$Commentscolumn['subject']},\n                   {$Commentscolumn['pid']}\n              FROM {$Commentstable}\n         LEFT JOIN {$Usertable}\n                ON {$Commentscolumn['name']} = {$Usercolumn['uname']}";
    $result = DBUtil::executeSQL($sql);
    if ($result == false) {
        return LogUtil::registerError('News migration: DB Error');
    }
    // array to rebuild the patents
    $comments = array(0 => array('newid' => -1));
    // loop through the old comments and insert them one by one into the DB
    $items = DBUtil::marshalObjects($result, array('tid', 'sid', 'date', 'uid', 'comment', 'subject', 'replyto'));
    foreach ($items as $item) {
        // set the correct user id for anonymous users
        if (empty($item['uid'])) {
            $item['uid'] = 1;
        }
        $id = ModUtil::apiFunc('EZComments', 'user', 'create', array('mod' => 'News', 'objectid' => DataUtil::formatForStore($item['sid']), 'url' => ModUtil::url('News', 'user', 'display', array('sid' => $item['sid'])), 'comment' => $item['comment'], 'subject' => $item['subject'], 'uid' => $item['uid'], 'date' => $item['date']));
        if (!$id) {
            return LogUtil::registerError('News migration: Error creating comment');
        }
        $comments[$item['tid']] = array('newid' => $id, 'pid' => $item['replyto']);
    }
    // rebuild the links to the parents
    $tids = array_keys($comments);
    foreach ($tids as $tid) {
        if ($tid != 0) {
            $v = $comments[$tid];
            $sql = "UPDATE {$EZCommentstable}\n                       SET {$EZCommentscolumn['replyto']} = '" . $comments[$v['pid']]['newid'] . "'\n                     WHERE {$EZCommentscolumn['id']} = '{$v['newid']}'";
            $result = DBUtil::executeSQL($sql);
        }
    }
    // activate the ezcomments hook for the news module
    ModUtil::apiFunc('Modules', 'admin', 'enablehooks', array('callermodname' => 'News', 'hookmodname' => 'EZComments'));
    return LogUtil::registerStatus('News migration successful');
}
开发者ID:rmaiwald,项目名称:EZComments,代码行数:61,代码来源:news.php

示例10: search

    /**
     * Search plugin main function
     **/
    public function search($args)
    {
        ModUtil::dbInfoLoad('Search');
        $dbtables = DBUtil::getTables();

        $searchTable = $dbtables['search_result'];
        $searchColumn = $dbtables['search_result_column'];
        $pageTable = $dbtables['content_page'];
        $pageColumn = $dbtables['content_page_column'];
        $contentTable = $dbtables['content_content'];
        $contentColumn = $dbtables['content_content_column'];
        $contentSearchTable = $dbtables['content_searchable'];
        $contentSearchColumn = $dbtables['content_searchable_column'];

        $sessionId = session_id();

        $where = Search_Api_User::construct_where($args, 
				array($contentSearchColumn['text']), null);
        $wheretitle = Search_Api_User::construct_where($args, 
				array($pageColumn['title']), $pageColumn['language']);

		// Direct SQL way of searching in titles and searchable content items 
		// for Pages and Content items that are visible/active
		// Optimization and conversion into DBUtil calls should be done
        $sql = "INSERT INTO $searchTable
            ($searchColumn[title],
            $searchColumn[text],
            $searchColumn[module],
            $searchColumn[extra],
            $searchColumn[created],
            $searchColumn[session])
            SELECT DISTINCT $pageColumn[title],
            $contentSearchColumn[text],
            'Content',
            $pageColumn[id],
            $pageColumn[cr_date] AS createdDate,
            '" . DataUtil::formatForStore($sessionId) . "'
            FROM $pageTable
            JOIN $contentTable
            ON $contentColumn[pageId] = $pageColumn[id]
            JOIN $contentSearchTable
            ON $contentSearchColumn[contentId] = $contentColumn[id]
            WHERE ($where or $wheretitle) AND $pageColumn[active] = 1 AND ($pageColumn[activeFrom] IS NULL OR $pageColumn[activeFrom] <= NOW()) AND ($pageColumn[activeTo] IS NULL OR $pageColumn[activeTo] >= NOW()) AND $contentColumn[active] = 1 AND $contentColumn[visiblefor] " . (UserUtil::isLoggedIn() ? '<=1' : '>=1');

        $dbresult = DBUtil::executeSQL($sql);
        if (!$dbresult) {
            return LogUtil::registerError($this->__('Error! Could not load any Content pages or items.'));
        }
        return true;
    }
开发者ID:projectesIF,项目名称:Sirius,代码行数:53,代码来源:Search.php

示例11: updateFile

 function updateFile($orgFileReference, $newFilename)
 {
     $dom = ZLanguage::getModuleDomain('mediashare');
     $pntable = pnDBGetTables();
     $mediadbTable = $pntable['mediashare_mediadb'];
     $mediadbColumn = $pntable['mediashare_mediadb_column'];
     $data = file_get_contents($newFilename);
     $bytes = count($data);
     $orgFileReference = DataUtil::formatForStore($orgFileReference);
     $sql = "UPDATE {$mediadbTable}\n                   SET {$mediadbColumn['data']} = '" . DataUtil::formatForStore($data) . "',\n                       {$mediadbColumn['bytes']} = '{$bytes}'\n                 WHERE {$mediadbColumn['fileref']} = '{$orgFileReference}'";
     $result = DBUtil::executeSQL($sql);
     if ($result === false) {
         return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('vfsHandlerDB.updateFile', 'Could not update the file information.'), $dom));
     }
     return true;
 }
开发者ID:ro0f,项目名称:Mediashare,代码行数:16,代码来源:pnvfs_dbapi.php

示例12: getUsedModules

 /**
  * get Used Modules
  *
  * This function returns an array of the modules
  * for which a comment is available. This is used
  * for the "clean-up" feature that eliminates
  * orphaned comments after a module is deletd.
  *
  * @return list of all modules used
  */
 public function getUsedModules()
 {
     if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
         return LogUtil::registerPermissionError(ModUtil::url('EZComments', 'admin', 'main'));
     }
     $tables = DBUtil::getTables();
     $table = $tables['EZComments'];
     $column = $tables['EZComments_column'];
     // TODO Port to DBUtil
     $sql = "SELECT    {$column['modname']}\n                FROM      {$table}\n                GROUP BY  {$column['modname']}";
     $result = DBUtil::executeSQL($sql);
     if ($result == false) {
         return false;
     }
     return DBUtil::marshallFieldArray($result);
 }
开发者ID:rmaiwald,项目名称:EZComments,代码行数:26,代码来源:Admin.php

示例13: addCustomFieldsToTableDefinition

function addCustomFieldsToTableDefinition(&$columns)
{
    // get the global db prefix
    $prefix = System::getVar('prefix');
    $prefix = $prefix ? $prefix . '_' : '';
    $tablecustomfields = $prefix . "addressbook_customfields";
    $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
    if ($connection->import->tableExists($tablecustomfields)) {
        $sql = "SELECT cus_id FROM " . $tablecustomfields . " WHERE cus_id > 4 ORDER BY cus_id ASC";
        $result = DBUtil::executeSQL($sql, -1, -1, false, true);
        if ($result) {
            $customfields = DBUtil::marshallObjects($result, array('id'), true);
            foreach ($customfields as $cus) {
                $col_def = 'custom_' . $cus['id'];
                $columns[$col_def] = 'adr_' . $col_def;
            }
        }
    }
    return;
}
开发者ID:nmpetkov,项目名称:AddressBook,代码行数:20,代码来源:tables.php

示例14: Admin_Messages_searchapi_search

/**
 * Get all admin messages items that match the criteria
 *
 * @author Mark West, Jorn Wildt
 * @param bool args['activeonly'] only show active items
 * @return bool true/false on success/failure
 */
function Admin_Messages_searchapi_search($args)
{
    $dom = ZLanguage::getModuleDomain('Admin_Messages');
    // Security check
    if (!SecurityUtil::checkPermission('Admin_Messages::', '::', ACCESS_READ)) {
        return true;
    }
    // get the db and table info
    ModUtil::dbInfoLoad('Search');
    $pntable = DBUtil::getTables();
    $messagestable = $pntable['message'];
    $messagescolumn = $pntable['message_column'];
    $searchTable =& $pntable['search_result'];
    $searchColumn =& $pntable['search_result_column'];
    // form the where clause
    $where = '';
    if (!ModUtil::getVar('Admin_Messages', 'allowsearchinactive') || isset($args['activeonly']) && (bool) $args['activeonly']) {
        $where .= " {$messagescolumn['active']} = 1 AND ";
    }
    $where .= " ({$messagescolumn['date']}+{$messagescolumn['expire']} > '" . time() . "' OR {$messagescolumn['expire']} = 0) AND";
    $where .= search_construct_where($args, array($messagescolumn['title'], $messagescolumn['content']), $messagescolumn['language']);
    $sessionId = session_id();
    $sql = "\nSELECT\n   {$messagescolumn['mid']} as mid,\n   {$messagescolumn['title']} as title,\n   {$messagescolumn['content']} as text,\n   {$messagescolumn['date']} as date\nFROM {$messagestable}\nWHERE {$where}";
    $result = DBUtil::executeSQL($sql);
    if (!$result) {
        return LogUtil::registerError(__('Error! Could not load data.'));
    }
    $insertSql = "INSERT INTO {$searchTable}\n  ({$searchColumn['title']},\n   {$searchColumn['text']},\n   {$searchColumn['module']},\n   {$searchColumn['created']},\n   {$searchColumn['session']})\nVALUES ";
    // Process the result set and insert into search result table
    for (; !$result->EOF; $result->MoveNext()) {
        $message = $result->GetRowAssoc(2);
        if (SecurityUtil::checkPermission('Admin_Messages::', "{$message['title']}::{$message['mid']}", ACCESS_READ)) {
            $sql = $insertSql . '(' . '\'' . DataUtil::formatForStore($message['title']) . '\', ' . '\'' . DataUtil::formatForStore($message['text']) . '\', ' . '\'' . 'Admin_Messages' . '\', ' . '\'' . DataUtil::formatForStore(DateUtil::getDatetime($message['date'])) . '\', ' . '\'' . DataUtil::formatForStore($sessionId) . '\')';
            $insertResult = DBUtil::executeSQL($sql);
            if (!$insertResult) {
                return LogUtil::registerError(__('Error! Could not load data.', $dom));
            }
        }
    }
    return true;
}
开发者ID:robbrandt,项目名称:AdminMessages,代码行数:48,代码来源:pnsearchapi.php

示例15: EZComments_migrateapi_reviews

/**
 * Do the migration
 * 
 * With this function, the actual migration is done.
 * 
 * @return   boolean   true on sucessful migration, false else
 * @since    0.6
 */
function EZComments_migrateapi_reviews()
{
    // Security check
    if (!SecurityUtil::checkPermission('EZComments::', '::', ACCESS_ADMIN)) {
        return LogUtil::registerError('Reviews migration: Not Admin');
    }
    // Get datbase setup
    ModUtil::dbInfoLoad('Reviews', 'EZComments/migrateapi/Reviews', true);
    $tables = DBUtil::getTables();
    $Commentstable = $tables['reviews_comments'];
    $Commentscolumn = $tables['reviews_comments_column'];
    if (version_compare(PN_VERSION_NUM, '1', '>=')) {
        EZComments_get76xcolumns_reviews($Commentstable, $Commentscolumn);
    }
    if (is_null($Commentstable) || is_null($Commentscolumn)) {
        return LogUtil::registerError('Reviews migration: Comments tables not found');
    }
    $Usertable = $tables['users'];
    $Usercolumn = $tables['users_column'];
    // note: there's nothing we can do with the score......
    $sql = "SELECT {$Commentscolumn['cid']},\n                   {$Commentscolumn['rid']},\n                   {$Commentscolumn['date']}, \n                   {$Usercolumn['uid']}, \n                   {$Commentscolumn['comments']},\n                   {$Commentscolumn['score']}\n              FROM {$Commentstable}\n         LEFT JOIN {$Usertable}\n                ON {$Commentscolumn['userid']} = {$Usercolumn['uname']}";
    $result = DBUtil::executeSQL($sql);
    if ($result == false) {
        return LogUtil::registerError('Reviews migration: DB Error');
    }
    // loop through the old comments and insert them one by one into the DB
    $items = DBUtil::marshalObjects($result, array('cid', 'rid', 'date', 'uid', 'comment', 'score'));
    foreach ($items as $item) {
        // set the correct user id for anonymous users
        if (empty($item['uid'])) {
            $item['uid'] = 1;
        }
        $id = ModUtil::apiFunc('EZComments', 'user', 'create', array('mod' => 'Reviews', 'objectid' => DataUtil::formatForStore($item['rid']), 'url' => ModUtil::url('Reviews', 'user', 'display', array('id' => $item['rid'])), 'comment' => $item['comment'], 'subject' => '', 'uid' => $item['uid'], 'date' => $item['date']));
        if (!$id) {
            return LogUtil::registerError('Reviews migration: Error creating comment');
        }
    }
    // activate the ezcomments hook for the Reviews module
    ModUtil::apiFunc('Modules', 'admin', 'enablehooks', array('callermodname' => 'Reviews', 'hookmodname' => 'EZComments'));
    return LogUtil::registerStatus('Reviews migration successful');
}
开发者ID:rmaiwald,项目名称:EZComments,代码行数:49,代码来源:reviews.php


注:本文中的DBUtil::executeSQL方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。