1
1
Fork 0

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))
return $r[0]['id'];
$r = q("INSERT INTO `fcontact` ( `url`, `name`, `photo` ) VALUES ( '%s', '%s', '%s' ) ",
dbesc($nurl),
dbesc($name),
dbesc($photo)
);
$r = dba::insert('fcontact', array('url' => $nurl, 'name' => $name, 'photo' => $photo));
if (dbm::is_result($r)) {
$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) {
$r = q("INSERT INTO `ffinder` ( `uid`, `cid`, `fid` ) VALUES ( %d, %d, %d ) ",
intval($uid),
intval($cid),
intval($fid)
);
$r = dba::insert('ffinder', array('uid' => $uid, 'cid' => $cid, 'fid' => $fid));
return $r;
}

View file

@ -26,11 +26,7 @@ function group_add($uid,$name) {
}
return true;
}
$r = q("INSERT INTO `group` ( `uid`, `name` )
VALUES( %d, '%s' ) ",
intval($uid),
dbesc($name)
);
$r = dba::insert('group', array('uid' => $uid, 'name' => $name));
$ret = $r;
}
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
// -- It was just created at another time
if (! dbm::is_result($r)) {
$r = q("INSERT INTO `group_member` (`uid`, `gid`, `contact-id`)
VALUES( %d, %d, %d ) ",
intval($uid),
intval($gid),
intval($member)
);
$r = dba::insert('group_member', array('uid' => $uid, 'gid' => $gid, 'contact-id' => $member));
}
return $r;
}

View file

@ -83,7 +83,7 @@ function oembed_fetch_url($embedurl, $no_rich_type = false){
$j = json_decode($txt);
if ($j->type != "error") {
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);

View file

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

View file

@ -717,7 +717,7 @@ class App {
$r = q('SELECT `pid` FROM `process` WHERE `pid` = %d', intval(getmypid()));
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();
}

View file

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