]> git.mxchange.org Git - friendica.git/commitdiff
Now we have less than 100 insert commands, yeah
authorMichael <heluecht@pirati.ca>
Wed, 9 Aug 2017 23:02:57 +0000 (23:02 +0000)
committerMichael <heluecht@pirati.ca>
Wed, 9 Aug 2017 23:02:57 +0000 (23:02 +0000)
include/fcontact.php
include/group.php
include/oembed.php
include/plugin.php
src/App.php
src/ParseUrl.php

index b2706e51a0226e3cc13bfd6cafb4179a8c249fd6..a559ede3007c10aaa934b4a53a7fc94673326508 100644 (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;
 }
 
index ab805e68749ad80cf9de08bef527c195ef40de8b..8956d21c311d57df24a8a98a0704b119c5e66b45 100644 (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;
 }
index de597bbb37ab91bfe9604b01683b0c9dbb80d3ba..cb23517cdbabbfc17b44e502437143cd05e3cc8b 100755 (executable)
@@ -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);
index 60ef6138b9c4712145fb3c69ecf9d2e7c574936f..3a24235754a0c9c6af1cd546624d59697a36ba48 100644 (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;
 }}
 
index 4cdaa94ccd6f4b2ae4fb44ce7a15e0510e3c486a..c416a0b126d180bfda848a4e004607ed2886d5ab 100644 (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();
        }
index 9e21736a8465883f14961f6f17a52c5681117b5e..0de7663e4022cb2ac3bd88e5b801e8bfb1163675 100644 (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;
        }