本文整理汇总了PHP中DBUtil::insertObject方法的典型用法代码示例。如果您正苦于以下问题:PHP DBUtil::insertObject方法的具体用法?PHP DBUtil::insertObject怎么用?PHP DBUtil::insertObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBUtil
的用法示例。
在下文中一共展示了DBUtil::insertObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _createOperationLog
/**
* Creates a new logging instance.
*
* @param Doctrine_Event $event Event.
* @param int $opType I/U/D for Insert/Update/Delete.
*
* @return void
*/
private function _createOperationLog(Doctrine_Event $event, $opType = 'I')
{
$data = $event->getInvoker();
$tableName = $this->getTableNameFromEvent($event);
$idColumn = $this->getIdColumnFromEvent($event);
$log = array();
$log['object_type'] = $tableName;
$log['object_id'] = $data[$idColumn];
$log['op'] = $opType;
if ($opType == 'U') {
$oldValues = $data->getLastModified(true);
$diff = array();
foreach ($oldValues as $column => $oldValue) {
if (empty($oldValue) && isset($data[$column]) && !empty($data[$column])) {
$diff[$column] = 'I: ' . $data[$column];
} elseif (!empty($oldValue) && isset($data[$column]) && !empty($data[$column])) {
$diff[$column] = 'U: ' . $data[$column];
} elseif (!empty($oldValue) && empty($data[$column])) {
$diff[$column] = 'D: ' . $oldValue;
}
}
$log['diff'] = serialize($diff);
} else {
// Convert object to array (otherwise we serialize the record object)
$log['diff'] = serialize($data->toArray());
}
DBUtil::insertObject($log, 'objectdata_log');
}
示例2: crear
/**
* Create a new topic
* @author: Albert Pï¿œrez Monfort (aperezm@xtec.cat)
* @param: args array with the topic information
* @return: identity of the new record created or false if error
*/
public function crear($args) {
$nomtema = FormUtil::getPassedValue('nomtema', isset($args['nomtema']) ? $args['nomtema'] : null, 'POST');
$descriu = FormUtil::getPassedValue('descriu', isset($args['descriu']) ? $args['descriu'] : null, 'POST');
$grup = FormUtil::getPassedValue('grup', isset($args['grup']) ? $args['grup'] : null, 'POST');
// Security check
if (!SecurityUtil::checkPermission('IWnoteboard::', '::', ACCESS_ADMIN)) {
return LogUtil::registerPermissionError();
}
// Needed argument
if (!isset($nomtema)) {
return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.'));
}
// Optional argument
if (!isset($descriu)) {
$descriu = '';
}
$item = array('nomtema' => $nomtema,
'descriu' => $descriu,
'grup' => $grup);
if (!DBUtil::insertObject($item, 'IWnoteboard_topics', 'tid')) {
return LogUtil::registerError($this->__('Error! Creation attempt failed.'));
}
// Return the id of the newly created item to the calling process
return $item['tid'];
}
示例3: Admin_Messages_adminapi_create
/**
* create a new Admin_Messages item
* @author Mark West
* @param string $args['title'] title of the admin message
* @param string $args['content'] text of the admin message
* @param string $args['language'] the language of the message
* @param int $args['active'] activation status of the message
* @param int $args['expire'] expiry date of the message
* @param int $args['view'] who can view the message
* @return mixed Admin_Messages item ID on success, false on failure
*/
function Admin_Messages_adminapi_create($args)
{
$dom = ZLanguage::getModuleDomain('Admin_Messages');
// Argument check
if (!isset($args['title']) || !isset($args['content']) || !isset($args['language']) || !isset($args['active']) || !isset($args['expire']) || !isset($args['view'])) {
return LogUtil::registerArgsError();
}
if (empty($args['title']) && empty($args['content'])) {
return LogUtil::registerArgsError();
}
// Security check
if (!SecurityUtil::checkPermission('Admin_Messages::', '::', ACCESS_ADD)) {
return LogUtil::registerPermissionError();
}
// create the item array
$item = array('title' => $args['title'], 'content' => $args['content'], 'language' => $args['language'], 'active' => $args['active'], 'view' => $args['view']);
// add some additional modified values
if ($args['expire'] < 0) {
$args['expire'] = 0;
}
$item['expire'] = $args['expire'] * 86400;
// turns days into seconds
$item['date'] = time();
if (!DBUtil::insertObject($item, 'message', 'mid')) {
return LogUtil::registerError(__('Error! Could not create the new item.', $dom));
}
// Let any hooks know that we have created a new item.
ModUtil::callHooks('item', 'create', $item['mid'], array('module' => 'Admin_Messages'));
// Return the id of the newly created item to the calling process
return $item['mid'];
}
示例4: Yes
/**
* Insert a new URL reference into the database
*
* @param $args['ref'] Reference of the item
* @param $args['url'] URL website
* @param $args['description'] Reference description
* @param $args['scrolls'] The iframe show the scrolls
1 - Yes (auto)
0 - No
* @param $args['width'] Width of the iframe
* @param $args['height'] Height of the iframe
* @param $args['widthunit'] Unit used in the width specified
% - percentual
px - pixels
* @return mixed Reference ID on success, false on failure
*/
public function create($args) {
// Optiona argument
if (!isset($args['description']))
$args['description'] = '';
// Check if args have arrived properly
if (!isset($args['url']) || !isset($args['ref'])) {
return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.'));
}
$args['scrolls'] = ($args['scrolls'] == 'on') ? '1' : '0';
// Security check
if (!SecurityUtil::checkPermission('IWwebbox::', '::', ACCESS_ADD)) {
return LogUtil::registerPermissionError();
}
if (!DBUtil::insertObject($args, 'IWwebbox', 'pid')) {
return LogUtil::registerError($this->__('Error! Creation attempt failed.'));
}
// Let any hooks know that we have created a new item
ModUtil::callHooks('item', 'create', $args['pid'], array('module' => 'IWwebbox'));
return $args['pid'];
}
示例5: create
/**
* create a new RSS item
* @param $args['feedname'] name of the item
* @param $args['number'] number of the item
* @return mixed RSS item ID on success, false on failure
*/
public function create($args)
{
// Argument check
if (!isset($args['name']) || !isset($args['url'])) {
return LogUtil::registerArgsError();
}
// Security check
if (!SecurityUtil::checkPermission('Feeds::Item', "$args[name]::", ACCESS_ADD)) {
return LogUtil::registerPermissionError();
}
// check for maximum length to avoid cutting off URLs
if (strlen($args['url'] > 255)) {
return LogUtil::registerError($this->__('The provided URL is too long (200 chars max.).'));
}
// Check for a protocol Magpie RSS (more exactly Snoopy) can handle.
$url_parts = parse_url($args['url']);
if (!isset($url_parts['scheme']) || ($url_parts['scheme'] != 'http' && $url_parts['scheme'] != 'https')) {
return LogUtil::registerError($this->__('Invalid protocol selected. Only http and https are allowed.'));
}
// define the permalink title if not present
if (!isset($args['urltitle']) || empty($args['urltitle'])) {
$args['urltitle'] = DataUtil::formatPermalink($args['name']);
}
if (!DBUtil::insertObject($args, 'feeds', 'fid')) {
return LogUtil::registerError($this->__('Error! Creation attempt failed.'));
}
// Return the id of the newly created item to the calling process
return $args['fid'];
}
示例6: create
/**
* create a new page
* @param $args['title'] name of the item
* @param $args['content'] content of the item
* @param $args['language'] language of the item
* @return mixed page ID on success, false on failure
*/
public function create($args)
{
// Argument check
if (!isset($args['title']) || !isset($args['content'])) {
return LogUtil::registerArgsError();
}
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Pages::', $args['title'] . '::', ACCESS_ADD), LogUtil::getErrorMsgPermission());
// defaults
if (!isset($args['language'])) {
$args['language'] = '';
}
if (!isset($args['displaywrapper'])) {
$args['displaywrapper'] = 0;
}
if (!isset($args['displaytitle'])) {
$args['displaytitle'] = 0;
}
if (!isset($args['displaycreated'])) {
$args['displaycreated'] = 0;
}
if (!isset($args['displayupdated'])) {
$args['displayupdated'] = 0;
}
if (!isset($args['displaytextinfo'])) {
$args['displaytextinfo'] = 0;
}
if (!isset($args['displayprint'])) {
$args['displayprint'] = 0;
}
// define the permalink title if not present
$urltitlecreatedfromtitle = false;
if (!isset($args['urltitle']) || empty($args['urltitle'])) {
$args['urltitle'] = DataUtil::formatPermalink($args['title']);
$urltitlecreatedfromtitle = true;
}
if (ModUtil::apiFunc('Pages', 'admin', 'checkuniquepermalink', $args) == false) {
$args['urltitle'] = '';
if ($urltitlecreatedfromtitle == true) {
LogUtil::registerStatus($this->__('The permalinks retrieved from the title has to be unique!'));
} else {
LogUtil::registerStatus($this->__('The permalink has to be unique!'));
}
LogUtil::registerStatus($this->__('The permalink has been removed, please update the page with a correct and unique permalink'));
}
if (!DBUtil::insertObject($args, 'pages', 'pageid')) {
return LogUtil::registerError($this->__('Error! Creation attempt failed.'));
}
// An item was created, so we clear all cached pages of the items list.
ModUtil::apiFunc('Pages', 'user', 'clearItemCache', $args);
// Return the id of the newly created item to the calling process
return $args['pageid'];
}
示例7: Install
/**
* Initialise the IWmenu module creating module tables and module vars
* @author Albert Perez Monfort (aperezm@xtec.cat)
* @return bool true if successful, false otherwise
*/
public function Install() {
// Checks if module IWmain is installed. If not returns error
$modid = ModUtil::getIdFromName('IWmain');
$modinfo = ModUtil::getInfo($modid);
if ($modinfo['state'] != 3) {
return LogUtil::registerError($this->__('Module IWmain is needed. You have to install the IWmain module previously to install it.'));
}
// Check if the version needed is correct
$versionNeeded = '3.0.0';
if (!ModUtil::func('IWmain', 'admin', 'checkVersion', array('version' => $versionNeeded))) {
return false;
}
// Create module table
if (!DBUtil::createTable('IWmenu'))
return false;
//Create indexes
$pntable = DBUtil::getTables();
$c = $pntable['IWmenu_column'];
if (!DBUtil::createIndex($c['id_parent'], 'IWmenu', 'id_parent'))
return false;
//Create module vars
ModUtil::setVar('IWmenu', 'height', 26); // Default height
ModUtil::setVar('IWmenu', 'width', 200); // Default width
ModUtil::setVar('IWmenu', 'imagedir', "menu"); // Default directori of menu images
// checks if module vhmenu exists. If it exists import module vhmenu tables
$modid = ModUtil::getIdFromName('IWmenu');
$modinfo = ModUtil::getInfo($modid);
if ($modinfo['state'] == 3) {
// get the objects from the db
ModUtil::load('IWvhmenu', 'user');
$items = DBUtil::selectObjectArray('IWvhmenu');
if ($items) {
foreach ($items as $item) {
$groups = str_replace('|0', '', $item['groups']);
$groups = substr($groups, 1, strlen($groups));
$itemArray = array('text' => $item['text'],
'url' => $item['url'],
'icon' => '',
'id_parent' => $item['id_parent'],
'groups' => $groups,
'active' => $item['active'],
'target' => $item['target'],
'descriu' => $item['descriu']);
DBUtil::insertObject($itemArray, 'IWmenu', 'mid');
}
}
}
return true;
}
示例8: addfavourite
function addfavourite()
{
$objectid = FormUtil::getPassedValue('objectid', null, 'POST');
$userid = FormUtil::getPassedValue('userid', null, 'POST');
if (!SecurityUtil::checkPermission('AddressBook::', "::", ACCESS_COMMENT)) {
AjaxUtil::error($this->__('Error! No authorization to access this module.'));
}
$obj['favadr_id'] = $objectid;
$obj['favuser_id'] = $userid;
DBUtil::insertObject($obj, 'addressbook_favourites');
return;
}
示例9: install
/**
* Install the Reviews application.
*
* @return boolean True on success, or false.
*/
public function install()
{
// Check if upload directories exist and if needed create them
try {
$controllerHelper = new Reviews_Util_Controller($this->serviceManager);
$controllerHelper->checkAndCreateAllUploadFolders();
} catch (\Exception $e) {
return LogUtil::registerError($e->getMessage());
}
// create all tables from according entity definitions
try {
DoctrineHelper::createSchema($this->entityManager, $this->listEntityClasses());
} catch (\Exception $e) {
if (System::isDevelopmentMode()) {
return LogUtil::registerError($this->__('Doctrine Exception: ') . $e->getMessage());
}
$returnMessage = $this->__f('An error was encountered while creating the tables for the %s extension.', array($this->name));
if (!System::isDevelopmentMode()) {
$returnMessage .= ' ' . $this->__('Please enable the development mode by editing the /config/config.php file in order to reveal the error details.');
}
return LogUtil::registerError($returnMessage);
}
// set up all our vars with initial values
$this->setVar('enablecategorization', false);
$this->setVar('pagesize', 10);
$this->setVar('scoreForUsers', false);
$this->setVar('addcategorytitletopermalink', false);
$categoryRegistryIdsPerEntity = array();
// add default entry for category registry (property named Main)
include_once 'modules/Reviews/lib/Reviews/Api/Base/Category.php';
include_once 'modules/Reviews/lib/Reviews/Api/Category.php';
$categoryApi = new Reviews_Api_Category($this->serviceManager);
$categoryGlobal = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/Global');
$registryData = array();
$registryData['modname'] = $this->name;
$registryData['table'] = 'Review';
$registryData['property'] = $categoryApi->getPrimaryProperty(array('ot' => 'Review'));
$registryData['category_id'] = $categoryGlobal['id'];
$registryData['id'] = false;
if (!DBUtil::insertObject($registryData, 'categories_registry')) {
LogUtil::registerError($this->__f('Error! Could not create a category registry for the %s entity.', array('review')));
}
$categoryRegistryIdsPerEntity['review'] = $registryData['id'];
// create the default data
$this->createDefaultData($categoryRegistryIdsPerEntity);
// register persistent event handlers
$this->registerPersistentEventHandlers();
// register hook subscriber bundles
HookUtil::registerSubscriberBundles($this->version->getHookSubscriberBundles());
// initialisation successful
return true;
}
示例10: createFile
function createFile($filename, $args)
{
$dom = ZLanguage::getModuleDomain('mediashare');
$fileReference = "vfsdb/{$args['baseFileRef']}-{$args['fileMode']}.{$args['fileType']}";
$data = file_get_contents($filename);
$bytes = count($data);
$record = array('fileref' => $fileReference, 'mode' => $args['fileMode'], 'type' => $args['fileType'], 'bytes' => $bytes, 'data' => $data);
$result = DBUtil::insertObject($record, 'mediashare_mediadb', 'id');
if ($result === false) {
return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('vfsHandlerDB.createFile', 'Could not retrieve insert the file information.'), $dom));
}
return $fileReference;
}
示例11: mediashare_sourcesapi_addSource
function mediashare_sourcesapi_addSource($args)
{
$dom = ZLanguage::getModuleDomain('mediashare');
$title = $args['title'];
$name = $args['name'];
$pntable = pnDBGetTables();
$sourcesColumn = $pntable['mediashare_sources_column'];
$source = array('name' => $name, 'title' => $title, 'formEncType' => '');
$result = DBUtil::insertObject($source, 'mediashare_sources', 'id');
if ($result === false) {
return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('sourcesapi.addSource', 'Could not add a source.'), $dom));
}
return true;
}
示例12: upgrade
/**
* Upgrade the MUVideo application from an older version.
*
* If the upgrade fails at some point, it returns the last upgraded version.
*
* @param integer $oldVersion Version to upgrade from.
*
* @return boolean True on success, false otherwise.
*/
public function upgrade($oldVersion)
{
// Upgrade dependent on old version number
switch ($oldVersion) {
case '1.0.0':
// update the database schema
try {
DoctrineHelper::updateSchema($this->entityManager, $this->listEntityClasses());
} catch (\Exception $e) {
if (System::isDevelopmentMode()) {
return LogUtil::registerError($this->__('Doctrine Exception: ') . $e->getMessage());
}
return LogUtil::registerError($this->__f('An error was encountered while updating tables for the %s extension.', array($this->getName())));
}
$categoryRegistryIdsPerEntity = array();
// add default entry for category registry (property named Main)
include_once 'modules/MUVideo/lib/MUVideo/Api/Base/Category.php';
include_once 'modules/MUVideo/lib/MUVideo/Api/Category.php';
$categoryApi = new MUVideo_Api_Category($this->serviceManager);
$categoryGlobal = CategoryUtil::getCategoryByPath('/__SYSTEM__/Modules/Global');
$registryData = array();
$registryData['modname'] = $this->name;
$registryData['table'] = 'Collection';
$registryData['property'] = $categoryApi->getPrimaryProperty(array('ot' => 'Collection'));
$registryData['category_id'] = $categoryGlobal['id'];
$registryData['id'] = false;
if (!DBUtil::insertObject($registryData, 'categories_registry')) {
LogUtil::registerError($this->__f('Error! Could not create a category registry for the %s entity.', array('collection')));
}
$categoryRegistryIdsPerEntity['collection'] = $registryData['id'];
$registryData = array();
$registryData['modname'] = $this->name;
$registryData['table'] = 'Movie';
$registryData['property'] = $categoryApi->getPrimaryProperty(array('ot' => 'Movie'));
$registryData['category_id'] = $categoryGlobal['id'];
$registryData['id'] = false;
if (!DBUtil::insertObject($registryData, 'categories_registry')) {
LogUtil::registerError($this->__f('Error! Could not create a category registry for the %s entity.', array('movie')));
}
$categoryRegistryIdsPerEntity['movie'] = $registryData['id'];
// unregister persistent event handlers
EventUtil::unregisterPersistentModuleHandlers($this->name);
// register persistent event handlers
$this->registerPersistentEventHandlers();
case '1.1.0':
// for later updates
}
// update successful
return true;
}
示例13: mediashare_invitationapi_createInvitationId
function mediashare_invitationapi_createInvitationId($args)
{
$dom = ZLanguage::getModuleDomain('mediashare');
do {
$key = mediashareCreateInvitationKey();
$record = array('albumId' => (int) $args['albumId'], 'created' => DateUtil::getDatetime(), 'key' => $key, 'email' => $args['email'], 'subject' => $args['subject'], 'text' => $args['text'], 'sender' => $args['sender'], 'expires' => !empty($args['expires']) ? $args['expires'] : null);
$result = DBUtil::insertObject($record, 'mediashare_invitation', 'id');
if ($result == false) {
return LogUtil::registerError(__f('Error in %1$s: %2$s.', array('invitationapi.createInvitationId', 'Could not create the invitation.'), $dom));
}
} while (false);
// FIXME: add "key exists" check
return $key;
}
示例14: addmodule
public function addmodule($args)
{
$this->throwForbiddenUnless(SecurityUtil::checkPermission('Scribite::', '::', ACCESS_ADMIN), LogUtil::getErrorMsgPermission());
// Argument check
if (!isset($args['modulename']) || !isset($args['modfuncs']) || !isset($args['modareas']) || !isset($args['modeditor'])) {
return LogUtil::registerError($this->__('Error! Could not do what you wanted. Please check your input.'));
}
// add item
$additem = array('modname' => $args['modulename'], 'modfuncs' => serialize(explode(',', $args['modfuncs'])), 'modareas' => serialize(explode(',', $args['modareas'])), 'modeditor' => $args['modeditor']);
if (!DBUtil::insertObject($additem, 'scribite', 'mid', false)) {
return LogUtil::registerError($this->__('Configuration not updated'));
}
return true;
}
示例15: search
/**
* Search plugin main function
**/
public function search($args)
{
if (!SecurityUtil::checkPermission('News::', '::', ACCESS_READ)) {
return true;
}
ModUtil::dbInfoLoad('Search');
$tables = DBUtil::getTables();
$newsColumn = $tables['news_column'];
$where = Search_Api_User::construct_where($args,
array($newsColumn['title'],
$newsColumn['hometext'],
$newsColumn['bodytext']),
$newsColumn['language']);
// Only search in published articles that are currently visible
$where .= " AND ({$newsColumn['published_status']} = '0')";
$date = DateUtil::getDatetime();
$where .= " AND ('$date' >= {$newsColumn['from']} AND ({$newsColumn['to']} IS NULL OR '$date' <= {$newsColumn['to']}))";
$sessionId = session_id();
ModUtil::loadApi('News', 'user');
$permChecker = new News_ResultChecker($this->getVar('enablecategorization'), $this->getVar('enablecategorybasedpermissions'));
$articles = DBUtil::selectObjectArrayFilter('news', $where, null, null, null, '', $permChecker, null);
foreach ($articles as $article)
{
$item = array(
'title' => $article['title'],
'text' => $article['hometext'],
'extra' => $article['sid'],
'created' => $article['from'],
'module' => 'News',
'session' => $sessionId
);
$insertResult = DBUtil::insertObject($item, 'search_result');
if (!$insertResult) {
return LogUtil::registerError($this->__('Error! Could not load any articles.'));
}
}
return true;
}