Now we have less than 100 insert commands, yeah

This commit is contained in:
Michael 2017-08-09 23:02:57 +00:00
parent c6b04aa922
commit 03b86d3766
6 changed files with 14 additions and 40 deletions

View File

@ -13,11 +13,7 @@ function fcontact_store($url,$name,$photo) {
if (dbm::is_result($r)) if (dbm::is_result($r))
return $r[0]['id']; return $r[0]['id'];
$r = q("INSERT INTO `fcontact` ( `url`, `name`, `photo` ) VALUES ( '%s', '%s', '%s' ) ", $r = dba::insert('fcontact', array('url' => $nurl, 'name' => $name, 'photo' => $photo));
dbesc($nurl),
dbesc($name),
dbesc($photo)
);
if (dbm::is_result($r)) { if (dbm::is_result($r)) {
$r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1", $r = q("SELECT `id` FROM `fcontact` WHERE `url` = '%s' LIMIT 1",
@ -31,11 +27,7 @@ function fcontact_store($url,$name,$photo) {
} }
function ffinder_store($uid,$cid,$fid) { function ffinder_store($uid,$cid,$fid) {
$r = q("INSERT INTO `ffinder` ( `uid`, `cid`, `fid` ) VALUES ( %d, %d, %d ) ", $r = dba::insert('ffinder', array('uid' => $uid, 'cid' => $cid, 'fid' => $fid));
intval($uid),
intval($cid),
intval($fid)
);
return $r; return $r;
} }

View File

@ -26,11 +26,7 @@ function group_add($uid,$name) {
} }
return true; return true;
} }
$r = q("INSERT INTO `group` ( `uid`, `name` ) $r = dba::insert('group', array('uid' => $uid, 'name' => $name));
VALUES( %d, '%s' ) ",
intval($uid),
dbesc($name)
);
$ret = $r; $ret = $r;
} }
return $ret; return $ret;
@ -144,12 +140,7 @@ function group_add_member($uid,$name,$member,$gid = 0) {
// we indicate success because the group member was in fact created // we indicate success because the group member was in fact created
// -- It was just created at another time // -- It was just created at another time
if (! dbm::is_result($r)) { if (! dbm::is_result($r)) {
$r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`) $r = dba::insert('group_member', array('uid' => $uid, 'gid' => $gid, 'contact-id' => $member));
VALUES( %d, %d, %d ) ",
intval($uid),
intval($gid),
intval($member)
);
} }
return $r; return $r;
} }

View File

@ -83,7 +83,7 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
$j = json_decode($txt); $j = json_decode($txt);
if ($j->type != "error") { if ($j->type != "error") {
dba::insert('oembed', array('url' => normalise_link($embedurl), dba::insert('oembed', array('url' => normalise_link($embedurl),
'content' => $txt, 'created' => datetime_convert())); 'content' => $txt, 'created' => datetime_convert()), true);
} }
Cache::set($a->videowidth.$embedurl, $txt, CACHE_DAY); Cache::set($a->videowidth.$embedurl, $txt, CACHE_DAY);

View File

@ -46,13 +46,10 @@ function install_plugin($plugin) {
$func = $plugin . '_install'; $func = $plugin . '_install';
$func(); $func();
$plugin_admin = (function_exists($plugin."_plugin_admin")?1:0); $plugin_admin = (function_exists($plugin."_plugin_admin") ? 1 : 0);
$r = q("INSERT INTO `addon` (`name`, `installed`, `timestamp`, `plugin_admin`) VALUES ( '%s', 1, %d , %d ) ", dba::insert('addon', array('name' => $plugin, 'installed' => true,
dbesc($plugin), 'timestamp' => $t, 'plugin_admin' => $plugin_admin));
intval($t),
$plugin_admin
);
// we can add the following with the previous SQL // we can add the following with the previous SQL
// once most site tables have been updated. // once most site tables have been updated.
@ -154,12 +151,8 @@ function register_hook($hook,$file,$function,$priority=0) {
if (dbm::is_result($r)) if (dbm::is_result($r))
return true; return true;
$r = q("INSERT INTO `hook` (`hook`, `file`, `function`, `priority`) VALUES ( '%s', '%s', '%s', '%s' ) ", $r = dba::insert('hook', array('hook' => $hook, 'file' => $file, 'function' => $function, 'priority' => $priority));
dbesc($hook),
dbesc($file),
dbesc($function),
dbesc($priority)
);
return $r; return $r;
}} }}

View File

@ -717,7 +717,7 @@ class App {
$r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid())); $r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));
if (!dbm::is_result($r)) { if (!dbm::is_result($r)) {
q("INSERT INTO `process` (`pid`,`command`,`created`) VALUES (%d, '%s', '%s')", intval(getmypid()), dbesc($command), dbesc(datetime_convert())); dba::insert('process', array('pid' => getmypid(), 'command' => $command, 'created' => datetime_convert()));
} }
dba::commit(); dba::commit();
} }

View File

@ -66,11 +66,9 @@ class ParseUrl {
$data = self::getSiteinfo($url, $no_guessing, $do_oembed); $data = self::getSiteinfo($url, $no_guessing, $do_oembed);
q("INSERT INTO `parsed_url` (`url`, `guessing`, `oembed`, `content`, `created`) VALUES ('%s', %d, %d, '%s', '%s') dba::insert('parsed_url', array('url' => normalise_link($url), 'guessing' => !$no_guessing,
ON DUPLICATE KEY UPDATE `content` = '%s', `created` = '%s'", 'oembed' => $do_oembed, 'content' => serialize($data),
dbesc(normalise_link($url)), intval(!$no_guessing), intval($do_oembed), 'created' => datetime_convert()), true);
dbesc(serialize($data)), dbesc(datetime_convert()),
dbesc(serialize($data)), dbesc(datetime_convert()));
return $data; return $data;
} }