本文整理汇总了PHP中PHPWS_DB::insert方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPWS_DB::insert方法的具体用法?PHP PHPWS_DB::insert怎么用?PHP PHPWS_DB::insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPWS_DB
的用法示例。
在下文中一共展示了PHPWS_DB::insert方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public function save()
{
$result = parent::save();
if (PHPWS_Error::isError($result)) {
return $result;
}
$db = new PHPWS_DB('analytics_tracker_owa');
$db->addWhere('id', $this->id);
$result = $db->select();
if (PHPWS_Error::logIfError($result)) {
return $result;
}
$db = new PHPWS_DB('analytics_tracker_owa');
$db->addValue('id', $this->id);
$db->addValue('owa_url', $this->owa_url);
$db->addValue('owa_site_id', $this->owa_site_id);
$db->addValue('owa_track_page_view', $this->owa_track_page_view);
$db->addValue('owa_track_clicks', $this->owa_track_clicks);
$db->addValue('owa_track_domstream', $this->owa_track_domstream);
if (count($result) < 1) {
$result = $db->insert(false);
} else {
$result = $db->update();
}
if (PHPWS_Error::logIfError($result)) {
return $result;
}
}
示例2: save
public function save()
{
$result = parent::save();
if (PHPWS_Error::isError($result)) {
return $result;
}
$db = new PHPWS_DB('analytics_tracker_piwik');
$db->addWhere('id', $this->id);
$result = $db->select();
if (PHPWS_Error::logIfError($result)) {
return $result;
}
$db = new PHPWS_DB('analytics_tracker_piwik');
$db->addValue('id', $this->id);
$db->addValue('piwik_url', $this->piwik_url);
$db->addValue('piwik_id', $this->piwik_id);
if (count($result) < 1) {
$result = $db->insert(false);
} else {
$result = $db->update();
}
if (PHPWS_Error::logIfError($result)) {
return $result;
}
}
示例3: saveObject
public static function saveObject(DbStorable $o)
{
$vars = $o->extractVars();
$tableName = $o::getTableName();
// Check if the key already exists
$query = "SELECT * FROM {$tableName} WHERE id = {$vars['id']}";
$result = \PHPWS_DB::getAll($query);
if (count($result) > 0) {
$exists = true;
} else {
$exists = false;
}
$db = new \PHPWS_DB($o->getTableName());
foreach ($vars as $key => $value) {
$db->addValue($key, $value);
}
if ($exists) {
$db->addWhere('id', $vars['id']);
$result = $db->update();
} else {
$result = $db->insert(false);
}
if (\PHPWS_Error::logIfError($result)) {
throw new \Exception($result->toString());
}
}
示例4: save
/**
* Saves the current activity log object to the db.
* Returns TRUE upon succes or a PEAR error object otherwise.
*/
public function save()
{
if ($this->id != 0) {
return FALSE;
}
$db = new PHPWS_DB('hms_activity_log');
$db->addValue('user_id', $this->get_user_id());
$db->addValue('timestamp', $this->get_timestamp());
$db->addValue('activity', $this->get_activity());
$db->addValue('actor', $this->get_actor());
$db->addValue('notes', $this->get_notes());
$result = $db->insert();
if (PHPWS_Error::logIfError($result)) {
throw new DatabaseException($result->toString());
} else {
return TRUE;
}
}
示例5: addUser
public function addUser($username, $classname, $instance = null)
{
$db = new PHPWS_DB('users');
$db->addWhere('username', $username);
$result = $db->select('row');
if (PHPWS_Error::logIfError($result)) {
throw new DatabaseException($result->toString());
}
if (is_null($result['id'])) {
throw new InvalidArgumentException('User name "' . $username . '" does not exist.');
}
$user_id = $result['id'];
$db = new PHPWS_DB('hms_user_role');
$db->addValue('user_id', $user_id);
$db->addValue('role', $this->id);
$db->addValue('class', strtolower($classname));
$db->addValue('instance', $instance);
$result = $db->insert();
if (PHPWS_Error::logIfError($result)) {
throw new DatabaseException($result->toString());
}
return true;
}
示例6: registerModule
public static function registerModule($module)
{
$db = new PHPWS_DB('phpws_key_register');
$db->addValue('module', $module);
return $db->insert();
}
示例7: save
/**
* updates the settings table
*/
public static function save($module)
{
if (!PHPWS_Settings::is_set($module)) {
return false;
}
$db = new PHPWS_DB('mod_settings');
$db->addWhere('module', $module);
$db->addWhere('setting_name', array_keys($GLOBALS['PHPWS_Settings'][$module]));
$db->delete();
$db->reset();
foreach ($GLOBALS['PHPWS_Settings'][$module] as $key => $value) {
if (empty($key)) {
continue;
}
$type = PHPWS_Settings::getType($value);
$db->addValue('module', $module);
$db->addValue('setting_name', $key);
$db->addValue('setting_type', $type);
switch ($type) {
case 1:
$db->addValue('small_num', (int) $value);
break;
case 2:
$db->addValue('large_num', (int) $value);
break;
case 3:
$db->addValue('small_char', $value);
break;
case 4:
$db->addValue('large_char', $value);
break;
}
$result = $db->insert();
if (PHPWS_Error::isError($result)) {
unset($GLOBALS['PHPWS_Settings'][$module]);
PHPWS_Settings::load($module);
return $result;
}
$db->reset();
}
unset($GLOBALS['PHPWS_Settings'][$module]);
PHPWS_Settings::load($module);
}
示例8: viewArchive
function viewArchive()
{
$content = $_SESSION['PHAT_FormManager']->menu();
$filename = PHPWS_HOME_DIR . 'files/phatform/archive/' . $_REQUEST['ARCHIVE_filename'];
if (is_file($filename)) {
$fileContent = file($filename);
} else {
$content .= dgettext('phatform', 'Archive file was not found.');
$content .= $this->viewArchives();
return $content;
}
if (empty($fileContent)) {
$content .= dgettext('phatform', 'File contained no content.');
$content .= $this->viewArchives();
return $content;
}
if (isset($_REQUEST['ARCHIVE_filename'])) {
$this->filename = $_REQUEST['ARCHIVE_filename'];
}
$buildingSQL = FALSE;
$endCreateSmnt = 0;
$formNum = NULL;
$sql = '';
// extract out table containing report data
for ($i = 0; $i < count($fileContent); $i++) {
$line = $fileContent[$i];
if (stristr($line, 'CREATE TABLE mod_phatform_form_') && ($line[0] != '#' && ($line[0] != '-' && $line[1] != '-'))) {
$buildingSQL = TRUE;
ereg('form_([0-9]+)', $line, $formNumArr);
$formNum = $formNumArr[1];
}
if ($buildingSQL == TRUE) {
$sql .= $line;
}
if ($buildingSQL == TRUE && stristr($line, ';')) {
$endCreateSmnt = $i + 6;
break;
}
}
if (empty($sql)) {
$content .= dgettext('phatform', 'File contained no archive to view.');
$content .= $this->viewArchives();
return $content;
}
$orgnTableName = 'mod_phatform_form_' . $formNum;
$newTableName = time() . $orgnTableName;
$sql = str_replace($orgnTableName, $newTableName, $sql);
$db = new PHPWS_DB('mod_phatform_forms');
$db->addWhere('archiveTableName', '%' . $orgnTableName . '%', 'LIKE');
$result = $db->select();
if ($result) {
foreach ($result as $form) {
if ($form['archiveFileName'] == $this->filename) {
return $this->readyViewArchive($form['id'], $form['archiveTableName']);
}
}
}
if (isset($_REQUEST['yes'])) {
// create main report table
PHPWS_DB::query(trim($sql));
$inserts = FALSE;
for ($j = $endCreateSmnt; $j < count($fileContent); $j++) {
$line = $fileContent[$j];
// check if finished inserting report data
if (stristr($line, 'CREATE TABLE')) {
break;
}
// check to see if finished with comments and spaces before insert commands
if (stristr($line, 'INSERT INTO ')) {
$inserts = TRUE;
}
// line is insertion data so put in database
if ($inserts) {
$sql = trim($line);
if (!empty($sql) && stristr($sql, $orgnTableName)) {
$sql = str_replace($orgnTableName, $newTableName, $sql);
PHPWS_DB::query(trim($sql));
} else {
break;
}
}
}
// create special archive form so keep track of archived forms
$data['owner'] = $_SESSION['OBJ_user']->username;
$data['editor'] = $_SESSION['OBJ_user']->username;
$data['ip'] = $_SERVER['REMOTE_ADDR'];
$data['label'] = dgettext('phatform', 'Archived Form');
$data['groups'] = NULL;
$data['created'] = time();
$data['updated'] = time();
$data['hidden'] = 1;
$data['approved'] = 1;
$data['saved'] = 1;
$data['archiveTableName'] = $newTableName;
$data['archiveFileName'] = $_REQUEST['ARCHIVE_filename'];
$db = new PHPWS_DB('mod_phatforms_forms');
$db->addValue($data);
$formId = $db->insert();
return $this->readyViewArchive($formId, $newTableName);
} else {
//.........这里部分代码省略.........
示例9: save
public function save()
{
if (empty($this->key_id) || empty($this->keywords)) {
return FALSE;
}
$db = new PHPWS_DB('search');
$db->addWhere('key_id', $this->key_id);
$db->delete();
$db->reset();
$key = new Key($this->key_id);
$db->addValue('key_id', $key->id);
$db->addValue('module', $key->module);
$db->addValue('created', $key->create_date);
if (is_array($this->keywords)) {
$keywords = implode(' ', $this->keywords);
} else {
$keywords = $this->keywords;
}
$db->addValue('keywords', $keywords);
return $db->insert();
}
示例10: convertToFileAssoc
public function convertToFileAssoc($table, $column, $type)
{
$db = new PHPWS_DB('fc_convert');
$db->addWhere('table_name', $table);
$db->addWhere('column_name', $column);
$result = $db->select();
if (PHPWS_Error::logIfError($result)) {
return false;
} elseif ($result) {
return true;
}
PHPWS_Core::initModClass('filecabinet', 'File_Assoc.php');
$db = new PHPWS_DB($table);
$db->addColumn('id');
$db->addColumn($column);
$db->setIndexBy('id');
$item = $db->select('col');
if (empty($item)) {
return true;
}
foreach ($item as $id => $item_id) {
$db->reset();
if (isset($item_converted[$item_id])) {
$file_assoc_id = $item_converted[$item_id];
$db->addValue($column, $file_assoc_id);
$db->addWhere('id', $id);
PHPWS_Error::logIfError($db->update());
} else {
$file_assoc = new FC_File_Assoc();
$file_assoc->file_type = $type;
$file_assoc->file_id = $item_id;
if (!PHPWS_Error::logIfError($file_assoc->save())) {
$db->addValue($column, $file_assoc->id);
$db->addWhere('id', $id);
if (PHPWS_Error::logIfError($db->update())) {
continue;
}
}
$item_converted[$item_id] = $file_assoc->id;
}
}
$db->reset();
$db->addValue('table_name', $table);
$db->addValue('column_name', $column);
PHPWS_Error::logIfError($db->insert());
return true;
}
示例11: lockBlock
public static function lockBlock($block_id, $key_id)
{
$block_id = (int) $block_id;
$key_id = (int) $key_id;
unset($_SESSION['Pinned_Blocks'][$block_id]);
$values['block_id'] = $block_id;
$values['key_id'] = $key_id;
$db = new PHPWS_DB('block_pinned');
$db->addWhere($values);
$result = $db->delete();
$db->addValue($values);
return $db->insert();
}
示例12: saveReasons
public function saveReasons()
{
// Save reason assignments
$db = new PHPWS_DB('checkin_rtos');
$db->addWhere('staff_id', $this->id);
$db->delete();
if ($this->filter_type & REASON_BITMASK) {
foreach ($this->_reasons as $rid) {
$db->reset();
$db->addValue('staff_id', $this->id);
$db->addValue('reason_id', $rid);
PHPWS_Error::logIfError($db->insert());
}
}
}
示例13: lottery_reserve
public function lottery_reserve($username, $requestor, $timestamp)
{
if ($this->is_lottery_reserved()) {
return FALSE;
}
$db = new PHPWS_DB('hms_lottery_reservation');
$db->addValue('asu_username', $username);
$db->addValue('requestor', $requestor);
$db->addValue('term', $this->term);
$db->addValue('bed_id', $this->id);
$db->addValue('expires_on', $timestamp);
$result = $db->insert();
if (PHPWS_Error::logIfError($result)) {
throw new DatabaseException($result->toString());
} else {
return TRUE;
}
}
示例14: saveParams
/**
* Saves the parameters from this report to the database.
*
* @throws DatabaseException
*/
public function saveParams()
{
$params = $this->getParams();
if (empty($params)) {
return;
}
$db = new PHPWS_DB('hms_report_param');
foreach ($params as $key => $value) {
$db->reset();
$db->addValue('report_id', $this->report->getId());
$db->addValue('param_name', $key);
$db->addValue('param_value', $value);
$result = $db->insert();
if (PHPWS_Error::logIfError($result)) {
throw new DatabaseException($result->toString());
}
}
}
示例15: users_update
//.........这里部分代码省略.........
+ Added error check to permission menu.
+ Error for missing user groups now reports user id.
+ Forgot password will work if CAPTCHA is disabled.
+ Using new savePermissions function instead of save.
+ Current_User was calling giveItemPermissions incorrectly.';
}
$content[] = '</pre>';
case version_compare($currentVersion, '2.4.7', '<'):
$content[] = '<pre>
2.4.7 changes
-------------------
+ Removed global authorization from change password check since it is not
written yet.
</pre>';
case version_compare($currentVersion, '2.4.9', '<'):
$content[] = '<pre>';
if (PHPWS_Core::isBranch() || PHPWS_Boost::inBranch()) {
$user_db = new PHPWS_DB('users');
$user_db->addWhere('deity', 1);
$user_db->addColumn('id');
$user_db->addColumn('username');
$user_db->setIndexBy('id');
$user_ids = $user_db->select('col');
if (!empty($user_ids) && !PHPWS_Error::logIfError($user_ids)) {
$group_db = new PHPWS_DB('users_groups');
foreach ($user_ids as $id => $username) {
$group_db->addWhere('user_id', $id);
$result = $group_db->select('row');
if (!$result) {
$group_db->reset();
$group_db->addValue('active', 1);
$group_db->addValue('name', $username);
$group_db->addValue('user_id', $id);
if (!PHPWS_Error::logIfError($group_db->insert())) {
$content[] = '--- Created missing group for user: ' . $username;
}
}
$group_db->reset();
}
}
}
$content[] = '2.4.9 changes
-----------------
+ Raised sql character limit in default username, display_name, and
group name installs.
+ Fixed bug with forbidden usernames
+ Added a function to group to remove its permissions upon deletion.
+ Bookmark won\'t return a user to a authkey page if their session dies.
+ Fixed bug #1850815 : unknown function itemIsAllowed in Permission.php
+ My Pages are unregistered on module removal.
+ My Page tab stays fixed.
</pre>';
case version_compare($currentVersion, '2.5.0', '<'):
$content[] = '<pre>';
$files = array('templates/forms/memberlist.tpl', 'templates/forms/userForm.tpl', 'javascript/generate/head.js', 'templates/manager/groups.tpl', 'templates/manager/users.tpl');
userUpdateFiles($files, $content);
$content[] = '2.5.0 changes
-------------------
+ Members\' names alphabetized
+ New user email notification added.
+ Fixed member listing dropping names past 10.
+ Added random password generator on user edit form.
+ Removed reference from Action.php causing php notice.
+ Changed redundant static method call in Permission.
+ Added dash to allowed display name characters.
+ Added \\pL to display name characters.