From ce6e81c68221a9f462af886626dc02fdfc26f8aa Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 3 Oct 2016 21:48:53 -0700 Subject: more backticks --- Zotlabs/Module/Profiles.php | 100 ++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 50 deletions(-) (limited to 'Zotlabs/Module/Profiles.php') diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 788673296..4cb8e7395 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -16,7 +16,7 @@ class Profiles extends \Zotlabs\Web\Controller { } if((argc() > 2) && (argv(1) === "drop") && intval(argv(2))) { - $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d AND `is_default` = 0 LIMIT 1", + $r = q("SELECT * FROM profile WHERE id = %d AND uid = %d AND is_default = 0 LIMIT 1", intval(argv(2)), intval(local_channel()) ); @@ -36,7 +36,7 @@ class Profiles extends \Zotlabs\Web\Controller { dbesc($profile_guid), intval(local_channel()) ); - $r = q("DELETE FROM `profile` WHERE `id` = %d AND `uid` = %d", + $r = q("DELETE FROM profile WHERE id = %d AND uid = %d", intval(argv(2)), intval(local_channel()) ); @@ -61,16 +61,16 @@ class Profiles extends \Zotlabs\Web\Controller { // check_form_security_token_redirectOnErr('/profiles', 'profile_new', 't'); - $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", + $r0 = q("SELECT id FROM profile WHERE uid = %d", intval(local_channel())); $num_profiles = count($r0); $name = t('Profile-') . ($num_profiles + 1); - $r1 = q("SELECT `fullname`, `photo`, `thumb` FROM `profile` WHERE `uid` = %d AND `is_default` = 1 LIMIT 1", + $r1 = q("SELECT fullname, photo, thumb FROM profile WHERE uid = %d AND is_default = 1 LIMIT 1", intval(local_channel())); - $r2 = q("INSERT INTO `profile` (`aid`, `uid` , `profile_guid`, `profile_name` , `fullname`, `photo`, `thumb`) + $r2 = q("INSERT INTO profile (aid, uid , profile_guid, profile_name , fullname, photo, thumb) VALUES ( %d, '%s', '%s', '%s', '%s', '%s', '%s' )", intval(get_account_id()), intval(local_channel()), @@ -81,7 +81,7 @@ class Profiles extends \Zotlabs\Web\Controller { dbesc($r1[0]['thumb']) ); - $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile_name` = '%s' LIMIT 1", + $r3 = q("SELECT id FROM profile WHERE uid = %d AND profile_name = '%s' LIMIT 1", intval(local_channel()), dbesc($name) ); @@ -97,12 +97,12 @@ class Profiles extends \Zotlabs\Web\Controller { check_form_security_token_redirectOnErr('/profiles', 'profile_clone', 't'); - $r0 = q("SELECT `id` FROM `profile` WHERE `uid` = %d", + $r0 = q("SELECT id FROM profile WHERE uid = %d", intval(local_channel())); $num_profiles = count($r0); $name = t('Profile-') . ($num_profiles + 1); - $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1", + $r1 = q("SELECT * FROM profile WHERE uid = %d AND id = %d LIMIT 1", intval(local_channel()), intval(\App::$argv[2]) ); @@ -119,13 +119,13 @@ class Profiles extends \Zotlabs\Web\Controller { dbesc_array($r1[0]); - $r2 = dbq("INSERT INTO `profile` (`" + $r2 = dbq("INSERT INTO profile (`" . implode("`, `", array_keys($r1[0])) . "`) VALUES ('" . implode("', '", array_values($r1[0])) . "')" ); - $r3 = q("SELECT `id` FROM `profile` WHERE `uid` = %d AND `profile_name` = '%s' LIMIT 1", + $r3 = q("SELECT id FROM profile WHERE uid = %d AND profile_name = '%s' LIMIT 1", intval(local_channel()), dbesc($name) ); @@ -143,7 +143,7 @@ class Profiles extends \Zotlabs\Web\Controller { if((argc() > 2) && (argv(1) === 'export')) { - $r1 = q("SELECT * FROM `profile` WHERE `uid` = %d AND `id` = %d LIMIT 1", + $r1 = q("SELECT * FROM profile WHERE uid = %d AND id = %d LIMIT 1", intval(local_channel()), intval(argv(2)) ); @@ -181,7 +181,7 @@ class Profiles extends \Zotlabs\Web\Controller { if($x) $id = $x[0]['id']; } - $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", + $r = q("SELECT * FROM profile WHERE id = %d AND uid = %d LIMIT 1", intval($id), intval(local_channel()) ); @@ -238,7 +238,7 @@ class Profiles extends \Zotlabs\Web\Controller { if((argc() > 1) && (argv(1) !== "new") && intval(argv(1))) { - $orig = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", + $orig = q("SELECT * FROM profile WHERE id = %d AND uid = %d LIMIT 1", intval(\App::$argv[1]), intval(local_channel()) ); @@ -484,41 +484,41 @@ class Profiles extends \Zotlabs\Web\Controller { } - $r = q("UPDATE `profile` - SET `profile_name` = '%s', - `fullname` = '%s', - `pdesc` = '%s', - `gender` = '%s', - `dob` = '%s', - `address` = '%s', - `locality` = '%s', - `region` = '%s', - `postal_code` = '%s', - `country_name` = '%s', - `marital` = '%s', - `partner` = '%s', - `howlong` = '%s', - `sexual` = '%s', - `homepage` = '%s', - `hometown` = '%s', - `politic` = '%s', - `religion` = '%s', - `keywords` = '%s', - `likes` = '%s', - `dislikes` = '%s', - `about` = '%s', - `interest` = '%s', - `contact` = '%s', - `channels` = '%s', - `music` = '%s', - `book` = '%s', - `tv` = '%s', - `film` = '%s', - `romance` = '%s', - `employment` = '%s', - `education` = '%s', - `hide_friends` = %d - WHERE `id` = %d AND `uid` = %d", + $r = q("UPDATE profile + SET profile_name = '%s', + fullname = '%s', + pdesc = '%s', + gender = '%s', + dob = '%s', + address = '%s', + locality = '%s', + region = '%s', + postal_code = '%s', + country_name = '%s', + marital = '%s', + partner = '%s', + howlong = '%s', + sexual = '%s', + homepage = '%s', + hometown = '%s', + politic = '%s', + religion = '%s', + keywords = '%s', + likes = '%s', + dislikes = '%s', + about = '%s', + interest = '%s', + contact = '%s', + channels = '%s', + music = '%s', + book = '%s', + tv = '%s', + film = '%s', + romance = '%s', + employment = '%s', + education = '%s', + hide_friends = %d + WHERE id = %d AND uid = %d", dbesc($profile_name), dbesc($name), dbesc($pdesc), @@ -617,7 +617,7 @@ class Profiles extends \Zotlabs\Web\Controller { if($x) $id = $x[0]['id']; } - $r = q("SELECT * FROM `profile` WHERE `id` = %d AND `uid` = %d LIMIT 1", + $r = q("SELECT * FROM profile WHERE id = %d AND uid = %d LIMIT 1", intval($id), intval(local_channel()) ); @@ -755,7 +755,7 @@ class Profiles extends \Zotlabs\Web\Controller { } else { - $r = q("SELECT * FROM `profile` WHERE `uid` = %d", + $r = q("SELECT * FROM profile WHERE uid = %d", local_channel()); if($r) { -- cgit v1.2.3 From 9bb847bb07ec017eb8e2ebb2764b7e34acf5e619 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 12 Oct 2016 18:15:12 -0700 Subject: remove the rest of the backticks from sql queries; replace with TQUOT const which is driver dependent --- Zotlabs/Module/Profiles.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Module/Profiles.php') diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 4cb8e7395..6f76cd1cf 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -119,9 +119,9 @@ class Profiles extends \Zotlabs\Web\Controller { dbesc_array($r1[0]); - $r2 = dbq("INSERT INTO profile (`" - . implode("`, `", array_keys($r1[0])) - . "`) VALUES ('" + $r2 = dbq("INSERT INTO profile (" . TQUOT + . implode(TQUOT . ", " . TQUOT, array_keys($r1[0])) + . TQUOT . ") VALUES ('" . implode("', '", array_values($r1[0])) . "')" ); -- cgit v1.2.3 From 6532972e61a2aa5e8517ebcca3113adb3c8f336d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 13 Oct 2016 00:30:41 -0700 Subject: additional array checking --- Zotlabs/Module/Profiles.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'Zotlabs/Module/Profiles.php') diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 6f76cd1cf..127304f92 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -117,13 +117,7 @@ class Profiles extends \Zotlabs\Web\Controller { $r1[0]['profile_name'] = dbesc($name); $r1[0]['profile_guid'] = dbesc(random_string()); - dbesc_array($r1[0]); - - $r2 = dbq("INSERT INTO profile (" . TQUOT - . implode(TQUOT . ", " . TQUOT, array_keys($r1[0])) - . TQUOT . ") VALUES ('" - . implode("', '", array_values($r1[0])) - . "')" ); + create_table_from_array('profile', $r1[0]); $r3 = q("SELECT id FROM profile WHERE uid = %d AND profile_name = '%s' LIMIT 1", intval(local_channel()), -- cgit v1.2.3 From 351f21c89fd8ad2e30dffa60735d6d14bcbce3a2 Mon Sep 17 00:00:00 2001 From: ilu33 Date: Sat, 22 Oct 2016 05:52:29 +0200 Subject: Postgres complaining again ... ```sql UPDATE abook SET abook_profile = (SELECT profile_guid AS FROM profile WHERE is_default = 1 AND uid = 13 LIMIT 1) WHERE abook_profile = '' AND abook_channel = 13 ; returned false ERROR: syntax error at or near "profile" LINE 1: ... SET abook_profile = (SELECT profile_guid AS FROM profile WH... ^ ``` --- Zotlabs/Module/Profiles.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module/Profiles.php') diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php index 127304f92..19a642a83 100644 --- a/Zotlabs/Module/Profiles.php +++ b/Zotlabs/Module/Profiles.php @@ -31,7 +31,7 @@ class Profiles extends \Zotlabs\Web\Controller { // move every contact using this profile as their default to the user default - $r = q("UPDATE abook SET abook_profile = (SELECT profile_guid AS FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1) WHERE abook_profile = '%s' AND abook_channel = %d ", + $r = q("UPDATE abook SET abook_profile = (SELECT profile_guid FROM profile WHERE is_default = 1 AND uid = %d LIMIT 1) WHERE abook_profile = '%s' AND abook_channel = %d ", intval(local_channel()), dbesc($profile_guid), intval(local_channel()) -- cgit v1.2.3