public static function setUpBeforeClass() { // add sample locations self::$first_location_id = $parent_location_id = commitAddObject('unit test location 0', NULL, 1562, NULL); for ($i = 1; $i <= self::$num_children; $i++) { $child_location_id = commitAddObject("unit test location {$i}", NULL, 1562, NULL); commitLinkEntities('location', $parent_location_id, 'location', $child_location_id); $parent_location_id = $child_location_id; } self::$last_location_id = $parent_location_id; // add sample objects usePreparedInsertBlade('Dictionary', array('chapter_id' => 1, 'dict_value' => 'unit test object type')); self::$objtype_id = lastInsertID(); commitSupplementOPC(self::$objtype_id, self::$objtype_id); self::$first_object_id = $parent_object_id = commitAddObject('unit test object 0', NULL, self::$objtype_id, NULL); for ($i = 1; $i <= self::$num_children; $i++) { $child_object_id = commitAddObject("unit test object {$i}", NULL, self::$objtype_id, NULL); commitLinkEntities('object', $parent_object_id, 'object', $child_object_id); $parent_object_id = $child_object_id; } self::$last_object_id = $parent_object_id; // add sample tags usePreparedInsertBlade('TagTree', array('tag' => 'unit test tag 0')); self::$first_tag_id = $parent_tag_id = lastInsertID(); for ($i = 1; $i <= self::$num_children; $i++) { usePreparedInsertBlade('TagTree', array('parent_id' => $parent_tag_id, 'tag' => "unit test tag {$i}")); $parent_tag_id = lastInsertID(); } self::$last_tag_id = $parent_tag_id; }
public function setUp() { // add sample data usePreparedInsertBlade('TagTree', array('tag' => 'unit test tag a')); $this->taga_id = lastInsertID(); usePreparedInsertBlade('TagTree', array('tag' => 'unit test tag b')); $this->tagb_id = lastInsertID(); usePreparedInsertBlade('TagTree', array('tag' => 'unit test tag c')); $this->tagc_id = lastInsertID(); }
public function insert() { //insert in si_invoice global $db_server; $sql = "INSERT \n\t\t\t\tINTO\n\t\t\t" . TB_PREFIX . "invoices (\n\t\t\t\tid, \n\t\t \t\tindex_id,\n\t\t\t\tdomain_id,\n\t\t\t\tbiller_id, \n\t\t\t\tcustomer_id, \n\t\t\t\ttype_id,\n\t\t\t\tpreference_id, \n\t\t\t\tdate, \n\t\t\t\tnote,\n\t\t\t\tcustom_field1,\n\t\t\t\tcustom_field2,\n\t\t\t\tcustom_field3,\n\t\t\t\tcustom_field4\n\t\t\t)\n\t\t\tVALUES\n\t\t\t(\n\t\t\t\tNULL,\n\t\t\t\t:index_id,\n\t\t\t\t:domain_id,\n\t\t\t\t:biller_id,\n\t\t\t\t:customer_id,\n\t\t\t\t:type_id,\n\t\t\t\t:preference_id,\n\t\t\t\t:date,\n\t\t\t\t:note,\n\t\t\t\t:custom_field1,\n\t\t\t\t:custom_field2,\n\t\t\t\t:custom_field3,\n\t\t\t\t:custom_field4\n\t\t\t\t)"; $pref_group = getPreference($this->preference_id, $this->domain_id); $sth = dbQuery($sql, ':index_id', index::next('invoice', $pref_group['index_group'], $this->domain_id), ':domain_id', $this->domain_id, ':biller_id', $this->biller_id, ':customer_id', $this->customer_id, ':type_id', $this->type_id, ':preference_id', $this->preference_id, ':date', $this->date, ':note', trim($this->note), ':custom_field1', $this->custom_field1, ':custom_field2', $this->custom_field2, ':custom_field3', $this->custom_field3, ':custom_field4', $this->custom_field4); #index::increment('invoice',$pref_group['index_group'], $domain_id,$this->biller_id); index::increment('invoice', $pref_group['index_group'], $this->domain_id); return lastInsertID(); }
public static function setUpBeforeClass() { // add sample data usePreparedInsertBlade('Dictionary', array('chapter_id' => 1, 'dict_value' => 'unit test object type')); self::$objtype_id = lastInsertID(); commitSupplementOPC(self::$objtype_id, self::$objtype_id); self::$objecta_id = commitAddObject('unit test object a', NULL, self::$objtype_id, NULL); self::$objectb_id = commitAddObject('unit test object b', NULL, self::$objtype_id, NULL); self::$objectc_id = commitAddObject('unit test object c', NULL, self::$objtype_id, NULL); self::$locationa_id = commitAddObject('unit test location a', NULL, 1562, NULL); self::$locationb_id = commitAddObject('unit test location b', NULL, 1562, NULL); self::$locationc_id = commitAddObject('unit test location c', NULL, 1562, NULL); }
function tableHandler() { $opspec = getOpspec(); switch ($opspec['action']) { case 'INSERT': switch ($opspec['table']) { case 'Attribute': $realm = 'attr'; break; case 'Chapter': $realm = 'chapter'; break; case 'Dictionary': $realm = 'dict'; break; case 'TagTree': $realm = 'tag'; break; case 'VLANSwitchTemplate': $realm = 'vst'; break; default: $realm = NULL; } usePreparedInsertBlade($opspec['table'], buildOpspecColumns($opspec, 'arglist')); if (isset($realm)) { lastCreated($realm, lastInsertID()); } $retcode = 48; break; case 'DELETE': usePreparedDeleteBlade($opspec['table'], buildOpspecColumns($opspec, 'arglist'), array_fetch($opspec, 'conjunction', 'AND')); $retcode = 49; break; case 'UPDATE': usePreparedUpdateBlade($opspec['table'], buildOpspecColumns($opspec, 'set_arglist'), buildOpspecColumns($opspec, 'where_arglist'), array_fetch($opspec, 'conjunction', 'AND')); $retcode = 51; break; default: throw new InvalidArgException('opspec/action', $opspec['action']); } showOneLiner($retcode); }
function commitAddFile($name, $type, $contents, $comment) { global $dbxlink; switch ($type) { case 'image/x-png': $type = 'image/png'; break; case 'image/pjpeg': $type = 'image/jpeg'; break; default: } try { $query = $dbxlink->prepare('INSERT INTO File (name, type, ctime, mtime, atime, contents, comment) VALUES (?, ?, NOW(), NOW(), NOW(), ?, ?)'); $query->bindParam(1, $name); $query->bindParam(2, $type); $query->bindParam(3, $contents, PDO::PARAM_LOB); $query->bindParam(4, $comment); $query->execute(); $file_id = lastInsertID(); usePreparedExecuteBlade('UPDATE File SET size = LENGTH(contents) WHERE id = ?', array($file_id)); return $file_id; } catch (PDOException $e) { throw convertPDOException($e); } }
function commitCreateRSPool($name = '', $vsconfig = '', $rsconfig = '', $tagidlist = array()) { usePreparedInsertBlade('IPv4RSPool', array('name' => !strlen($name) ? NULL : $name, 'vsconfig' => !strlen($vsconfig) ? NULL : $vsconfig, 'rsconfig' => !strlen($rsconfig) ? NULL : $rsconfig)); $new_pool_id = lastInsertID(); lastCreated('ipv4rspool', $new_pool_id); produceTagsForNewRecord('ipv4rspool', $tagidlist, $new_pool_id); return $new_pool_id; }
/** * @expectedException PDOException */ public function testInvalidateRackLink() { usePreparedInsertBlade('EntityLink', array('parent_entity_type' => 'row', 'parent_entity_id' => self::$rowa_id, 'child_entity_type' => 'rack', 'child_entity_id' => self::$racka_id)); usePreparedInsertBlade('EntityLink', array('parent_entity_type' => 'row', 'parent_entity_id' => self::$rowb_id, 'child_entity_type' => 'rack', 'child_entity_id' => self::$rackb_id)); usePreparedUpdateBlade('EntityLink', array('child_entity_id' => self::$racka_id), array('id' => lastInsertID())); }
function createVLANDomain() { assertStringArg('vdom_descr'); global $sic; usePreparedInsertBlade('VLANDomain', array('description' => $sic['vdom_descr'])); usePreparedInsertBlade('VLANDescription', array('domain_id' => lastInsertID(), 'vlan_id' => VLAN_DFL_ID, 'vlan_type' => 'compulsory', 'vlan_descr' => 'default')); return showFuncMessage(__FUNCTION__, 'OK'); }
function addNodePingCheck() { assertUIntArg('account_id'); assertStringArg('np_check_id'); $account = getNodePingAccount($_REQUEST['account_id']); $nodeping = new NodePingClient(array('token' => $account['token'])); $np_check = $nodeping->check->get(array('id' => $_REQUEST['np_check_id'], 'limit' => 1, 'clean' => true)); if (isset($np_check['error'])) { return showFuncMessage(__FUNCTION__, 'ERR1', array('Error: ' . $np_check['error'])); } usePreparedInsertBlade('NodePingCheck', array('account_id' => $_REQUEST['account_id'], 'np_check_id' => $_REQUEST['np_check_id'], 'label' => $np_check['label'], 'type' => $np_check['type'], 'target' => $np_check['parameters']['target'], 'check_interval' => $np_check['interval'])); $check_id = lastInsertID(); global $sic; usePreparedInsertBlade('NodePingLink', array('check_id' => $check_id, 'object_id' => $sic['object_id'])); return showFuncMessage(__FUNCTION__, 'OK', array(htmlspecialchars($np_check['label']))); }
trigger_error(sql_error(), E_USER_WARNING); fatal_error(TRUE, get_vocab("fatal_db_error")); } $area = lastInsertID($res); sqlsrv_free_stmt($res); //sql_mutex_unlock("users"); } elseif ($type == "room") { //$room = mrbsAddRoom($name, $area, $error, $description, $capacity); $f2f = $_POST['f2f']; $available = $_POST['available']; $dnka = $_POST['dnka']; $outreach = $_POST['outreach']; $nocount = $_POST['nocount']; $sql = "INSERT INTO [codes] (code, description, f2f, available, dnka, outreach, nocount, disabled)\n VALUES ('{$code}', '{$description}', {$f2f}, {$available}, {$dnka}, {$outreach}, {$nocount}, 0)"; $sql .= "; SELECT SCOPE_IDENTITY() AS IDENTITY_COLUMN_NAME"; /* if (!sql_mutex_lock("users")) { fatal_error(TRUE, get_vocab("failed_to_acquire")); }*/ $res = sql_query($sql); $ret = sqlsrv_rows_affected($res); if ($ret < 0) { trigger_error(sql_error(), E_USER_WARNING); fatal_error(TRUE, get_vocab("fatal_db_error")); } $area = lastInsertID($res); sqlsrv_free_stmt($res); //sql_mutex_unlock("users"); } $returl = "admin.php?success=" . (isset($area) ? 1 : 0) . (!empty($error) ? "&error={$error}" : ""); header("Location: {$returl}");