Skip to content

Commit 86976f2

Browse files
committed
Rename ORM to DB
1 parent a7e1789 commit 86976f2

34 files changed

Lines changed: 445 additions & 445 deletions

‎controller/footer.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function display($footer_style = null, $id = null, $p = null, $pid = null
5757
);
5858

5959
// Close Idiorm connection
60-
$pdo = \ORM::get_db();
60+
$pdo = \DB::get_db();
6161
$pdo = null;
6262

6363
// If we need to stop the application outside a route

‎extern.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ function output_html($feed)
359359
array('fp.read_forum' => '1')
360360
);
361361

362-
$cur_topic = \ORM::for_table('topics')->table_alias('t')
362+
$cur_topic = \DB::for_table('topics')->table_alias('t')
363363
->select_many($select_show_recent_topics)
364364
->left_outer_join('forum_perms', array('fp.forum_id', '=', 't.forum_id'), 'fp')
365365
->left_outer_join('forum_perms', array('fp.group_id', '=', $feather->user->g_id), null, true)
@@ -389,7 +389,7 @@ function output_html($feed)
389389
// Fetch $show posts
390390
$select_print_posts = array('p.id', 'p.poster', 'p.message', 'p.hide_smilies', 'p.posted', 'p.poster_email', 'p.poster_id', 'u.email_setting', 'u.email');
391391

392-
$result = \ORM::for_table('posts')
392+
$result = \DB::for_table('posts')
393393
->table_alias('p')
394394
->select_many($select_print_posts)
395395
->inner_join('users', array('u.id', '=', 'p.poster_id'), 'u')
@@ -431,7 +431,7 @@ function output_html($feed)
431431
$order_posted = isset($_GET['order']) && strtolower($_GET['order']) == 'posted';
432432
$forum_name = '';
433433

434-
$result = \ORM::for_table('topics')
434+
$result = \DB::for_table('topics')
435435
->table_alias('t');
436436

437437
// Were any forum IDs supplied?
@@ -450,7 +450,7 @@ function output_html($feed)
450450
array('fp.read_forum' => '1')
451451
);
452452

453-
$cur_topic = \ORM::for_table('forums')->table_alias('f')
453+
$cur_topic = \DB::for_table('forums')->table_alias('f')
454454
->left_outer_join('forum_perms', array('fp.forum_id', '=', 'f.id'), 'fp')
455455
->left_outer_join('forum_perms', array('fp.group_id', '=', $feather->user->g_id), null, true)
456456
->where_any_is($where_show_forum_name)
@@ -590,7 +590,7 @@ function output_html($feed)
590590
$where_fetch_users_online = array('idle' => '0');
591591
$order_by_fetch_users_online = array('ident');
592592

593-
$result = \ORM::for_table('online')
593+
$result = \DB::for_table('online')
594594
->select_many($select_fetch_users_online)
595595
->where($where_fetch_users_online)
596596
->order_by_many($order_by_fetch_users_online)
@@ -641,7 +641,7 @@ function output_html($feed)
641641
require FORUM_CACHE_DIR.'cache_users_info.php';
642642
}
643643

644-
$stats_query = \ORM::for_table('forums')
644+
$stats_query = \DB::for_table('forums')
645645
->select_expr('SUM(num_topics)', 'total_topics')
646646
->select_expr('SUM(num_posts)', 'total_posts')
647647
->find_one();

‎include/cache.php‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function generate_config_cache()
2121
global $db;
2222

2323
// Get the forum config from the DB
24-
$result = \ORM::for_table('config')->find_array();
24+
$result = \DB::for_table('config')->find_array();
2525

2626
$output = array();
2727
foreach ($result as $cur_config_item) {
@@ -42,7 +42,7 @@ function generate_bans_cache()
4242
global $db;
4343

4444
// Get the ban list from the DB
45-
$result = \ORM::for_table('bans')->find_array();
45+
$result = \DB::for_table('bans')->find_array();
4646

4747
$output = array();
4848
foreach ($result as $cur_ban) {
@@ -67,14 +67,14 @@ function generate_quickjump_cache($group_id = false)
6767
// If a group_id was supplied, we generate the quick jump cache for that group only
6868
if ($group_id !== false) {
6969
// Is this group even allowed to read forums?
70-
$read_board = \ORM::for_table('groups')->where('g_id', $group_id)
70+
$read_board = \DB::for_table('groups')->where('g_id', $group_id)
7171
->find_one_col('g_read_board');
7272

7373
$groups[$group_id] = $read_board;
7474
} else {
7575
// A group_id was not supplied, so we generate the quick jump cache for all groups
7676
$select_quickjump_all_groups = array('g_id', 'g_read_board');
77-
$result = \ORM::for_table('groups')->select_many($select_quickjump_all_groups)
77+
$result = \DB::for_table('groups')->select_many($select_quickjump_all_groups)
7878
->find_many();
7979

8080
foreach ($result as $row) {
@@ -95,7 +95,7 @@ function generate_quickjump_cache($group_id = false)
9595
);
9696
$order_by_generate_quickjump_cache = array('c.disp_position', 'c.id', 'f.disp_position');
9797

98-
$result = \ORM::for_table('categories')
98+
$result = \DB::for_table('categories')
9999
->table_alias('c')
100100
->select_many($select_generate_quickjump_cache)
101101
->inner_join('forums', array('c.id', '=', 'f.cat_id'), 'f')
@@ -143,7 +143,7 @@ function generate_censoring_cache()
143143
global $db;
144144

145145
$select_generate_censoring_cache = array('search_for', 'replace_with');
146-
$result = \ORM::for_table('censoring')->select_many($select_generate_censoring_cache)
146+
$result = \DB::for_table('censoring')->select_many($select_generate_censoring_cache)
147147
->find_many();
148148

149149
$search_for = $replace_with = array();
@@ -198,11 +198,11 @@ function generate_users_info_cache()
198198

199199
$stats = array();
200200

201-
$stats['total_users'] = (\ORM::for_table('users')->where_not_equal('group_id', FEATHER_UNVERIFIED)
201+
$stats['total_users'] = (\DB::for_table('users')->where_not_equal('group_id', FEATHER_UNVERIFIED)
202202
->count('id')) - 1;
203203

204204
$select_generate_users_info_cache = array('id', 'username');
205-
$last_user = \ORM::for_table('users')->select_many($select_generate_users_info_cache)
205+
$last_user = \DB::for_table('users')->select_many($select_generate_users_info_cache)
206206
->where_not_equal('group_id', FEATHER_UNVERIFIED)
207207
->order_by_desc('registered')
208208
->limit(1)
@@ -223,7 +223,7 @@ function generate_admins_cache()
223223
global $db;
224224

225225
// Get admins from the DB
226-
$result = \ORM::for_table('users')->select('id')
226+
$result = \DB::for_table('users')->select('id')
227227
->where('group_id', FEATHER_ADMIN)
228228
->find_array();
229229

‎include/common.php‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@
8080
require FEATHER_ROOT.'include/idiorm.php';
8181

8282
// TODO: handle drivers
83-
\ORM::configure('mysql:host='.$db_host.';dbname='.$db_name);
84-
\ORM::configure('username', $db_username);
85-
\ORM::configure('password', $db_password);
86-
\ORM::configure('logging', true);
87-
\ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
88-
\ORM::configure('id_column_overrides', array(
83+
\DB::configure('mysql:host='.$db_host.';dbname='.$db_name);
84+
\DB::configure('username', $db_username);
85+
\DB::configure('password', $db_password);
86+
\DB::configure('logging', true);
87+
\DB::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
88+
\DB::configure('id_column_overrides', array(
8989
$db_prefix.'groups' => 'g_id',
9090
));
9191

‎include/functions.php‎

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function check_cookie()
4545
$select_check_cookie = array('u.*', 'g.*', 'o.logged', 'o.idle');
4646
$where_check_cookie = array('u.id' => intval($cookie['user_id']));
4747

48-
$result = ORM::for_table('users')
48+
$result = \DB::for_table('users')
4949
->table_alias('u')
5050
->select_many($select_check_cookie)
5151
->inner_join('groups', array('u.group_id', '=', 'g.g_id'), 'g')
@@ -114,11 +114,11 @@ function set_preferences()
114114
case 'mysqli_innodb':
115115
case 'sqlite':
116116
case 'sqlite3':
117-
\ORM::for_table('online')->raw_execute('REPLACE INTO '.$feather->prefix.'online (user_id, ident, logged) VALUES(:user_id, :ident, :logged)', array(':user_id' => $feather->user->id, ':ident' => $feather->user->username, ':logged' => $feather->user->logged));
117+
\DB::for_table('online')->raw_execute('REPLACE INTO '.$feather->prefix.'online (user_id, ident, logged) VALUES(:user_id, :ident, :logged)', array(':user_id' => $feather->user->id, ':ident' => $feather->user->username, ':logged' => $feather->user->logged));
118118
break;
119119

120120
default:
121-
\ORM::for_table('online')->raw_execute('INSERT INTO '.$feather->prefix.'online (user_id, ident, logged) SELECT :user_id, :ident, :logged WHERE NOT EXISTS (SELECT 1 FROM '.$feather->prefix.'online WHERE user_id=:user_id)', array(':user_id' => $feather->user->id, ':ident' => $feather->user->username, ':logged' => $feather->user->logged));
121+
\DB::for_table('online')->raw_execute('INSERT INTO '.$feather->prefix.'online (user_id, ident, logged) SELECT :user_id, :ident, :logged WHERE NOT EXISTS (SELECT 1 FROM '.$feather->prefix.'online WHERE user_id=:user_id)', array(':user_id' => $feather->user->id, ':ident' => $feather->user->username, ':logged' => $feather->user->logged));
122122
break;
123123
}
124124

@@ -128,7 +128,7 @@ function set_preferences()
128128
} else {
129129
// Special case: We've timed out, but no other user has browsed the forums since we timed out
130130
if ($feather->user->logged < ($now-$feather->config['o_timeout_visit'])) {
131-
\ORM::for_table('users')->where('id', $feather->user->id)
131+
\DB::for_table('users')->where('id', $feather->user->id)
132132
->find_one()
133133
->set('last_visit', $feather->user->logged)
134134
->save();
@@ -137,7 +137,7 @@ function set_preferences()
137137

138138
$idle_sql = ($feather->user->idle == '1') ? ', idle=0' : '';
139139

140-
\ORM::for_table('online')->raw_execute('UPDATE '.$feather->prefix.'online SET logged='.$now.$idle_sql.' WHERE user_id=:user_id', array(':user_id' => $feather->user->id));
140+
\DB::for_table('online')->raw_execute('UPDATE '.$feather->prefix.'online SET logged='.$now.$idle_sql.' WHERE user_id=:user_id', array(':user_id' => $feather->user->id));
141141

142142
// Update tracked topics with the current expire time
143143
$cookie_tracked_topics = $feather->getCookie($cookie_name.'_track');
@@ -286,15 +286,15 @@ function set_default_user()
286286
case 'mysqli_innodb':
287287
case 'sqlite':
288288
case 'sqlite3':
289-
\ORM::for_table('online')->raw_execute('REPLACE INTO '.$feather->prefix.'online (user_id, ident, logged) VALUES(1, :ident, :logged)', array(':ident' => $remote_addr, ':logged' => $feather->user->logged));
289+
\DB::for_table('online')->raw_execute('REPLACE INTO '.$feather->prefix.'online (user_id, ident, logged) VALUES(1, :ident, :logged)', array(':ident' => $remote_addr, ':logged' => $feather->user->logged));
290290
break;
291291

292292
default:
293-
\ORM::for_table('online')->raw_execute('INSERT INTO '.$feather->prefix.'online (user_id, ident, logged) SELECT 1, :ident, :logged WHERE NOT EXISTS (SELECT 1 FROM '.$feather->prefix.'online WHERE ident=:ident)', array(':ident' => $remote_addr, ':logged' => $feather->user->logged));
293+
\DB::for_table('online')->raw_execute('INSERT INTO '.$feather->prefix.'online (user_id, ident, logged) SELECT 1, :ident, :logged WHERE NOT EXISTS (SELECT 1 FROM '.$feather->prefix.'online WHERE ident=:ident)', array(':ident' => $remote_addr, ':logged' => $feather->user->logged));
294294
break;
295295
}
296296
} else {
297-
\ORM::for_table('online')->where('ident', $remote_addr)
297+
\DB::for_table('online')->where('ident', $remote_addr)
298298
->update_many('logged', time());
299299
}
300300

@@ -352,7 +352,7 @@ function check_bans()
352352
foreach ($feather_bans as $cur_ban) {
353353
// Has this ban expired?
354354
if ($cur_ban['expire'] != '' && $cur_ban['expire'] <= time()) {
355-
\ORM::for_table('bans')->where('id', $cur_ban['id'])
355+
\DB::for_table('bans')->where('id', $cur_ban['id'])
356356
->delete_many();
357357
$bans_altered = true;
358358
continue;
@@ -382,7 +382,7 @@ function check_bans()
382382
}
383383

384384
if ($is_banned) {
385-
\ORM::for_table('online')->where('ident', $feather->user->username)
385+
\DB::for_table('online')->where('ident', $feather->user->username)
386386
->delete_many();
387387
message($lang_common['Ban message'].' '.(($cur_ban['expire'] != '') ? $lang_common['Ban message 2'].' '.strtolower(format_time($cur_ban['expire'], true)).'. ' : '').(($cur_ban['message'] != '') ? $lang_common['Ban message 3'].'<br /><br /><strong>'.feather_escape($cur_ban['message']).'</strong><br /><br />' : '<br /><br />').$lang_common['Ban message 4'].' <a href="mailto:'.feather_escape($feather_config['o_admin_email']).'">'.feather_escape($feather_config['o_admin_email']).'</a>.', true, true, true);
388388
}
@@ -435,7 +435,7 @@ function check_username($username, $errors, $exclude_id = null)
435435
// Check that the username (or a too similar username) is not already registered
436436
$query = (!is_null($exclude_id)) ? ' AND id!='.$exclude_id : '';
437437

438-
$result = \ORM::for_table('online')->raw_query('SELECT username FROM '.$feather->prefix.'users WHERE (UPPER(username)=UPPER(:username1) OR UPPER(username)=UPPER(:username2)) AND id>1'.$query, array(':username1' => $username, ':username2' => ucp_preg_replace('%[^\p{L}\p{N}]%u', '', $username)))->find_one();
438+
$result = \DB::for_table('online')->raw_query('SELECT username FROM '.$feather->prefix.'users WHERE (UPPER(username)=UPPER(:username1) OR UPPER(username)=UPPER(:username2)) AND id>1'.$query, array(':username1' => $username, ':username2' => ucp_preg_replace('%[^\p{L}\p{N}]%u', '', $username)))->find_one();
439439

440440
if ($result) {
441441
$busy = $result['username'];
@@ -466,26 +466,26 @@ function update_users_online()
466466
// Fetch all online list entries that are older than "o_timeout_online"
467467
$select_update_users_online = array('user_id', 'ident', 'logged', 'idle');
468468

469-
$result = \ORM::for_table('online')->select_many($select_update_users_online)
469+
$result = \DB::for_table('online')->select_many($select_update_users_online)
470470
->where_lt('logged', $now-$feather_config['o_timeout_online'])
471471
->find_many();
472472

473473
foreach ($result as $cur_user) {
474474
// If the entry is a guest, delete it
475475
if ($cur_user['user_id'] == '1') {
476-
\ORM::for_table('online')->where('ident', $cur_user['ident'])
476+
\DB::for_table('online')->where('ident', $cur_user['ident'])
477477
->delete_many();
478478
} else {
479479
// If the entry is older than "o_timeout_visit", update last_visit for the user in question, then delete him/her from the online list
480480
if ($cur_user['logged'] < ($now-$feather_config['o_timeout_visit'])) {
481-
\ORM::for_table('users')->where('id', $cur_user['user_id'])
481+
\DB::for_table('users')->where('id', $cur_user['user_id'])
482482
->find_one()
483483
->set('last_visit', $cur_user['logged'])
484484
->save();
485-
\ORM::for_table('online')->where('user_id', $cur_user['user_id'])
485+
\DB::for_table('online')->where('user_id', $cur_user['user_id'])
486486
->delete_many();
487487
} elseif ($cur_user['idle'] == '0') {
488-
\ORM::for_table('online')->where('user_id', $cur_user['user_id'])
488+
\DB::for_table('online')->where('user_id', $cur_user['user_id'])
489489
->update_many('idle', 1);
490490
}
491491
}
@@ -589,7 +589,7 @@ function update_forum($forum_id)
589589
// Get Slim current session
590590
$feather = \Slim\Slim::getInstance();
591591

592-
$stats_query = \ORM::for_table('topics')
592+
$stats_query = \DB::for_table('topics')
593593
->where('forum_id', $forum_id)
594594
->select_expr('COUNT(id)', 'total_topics')
595595
->select_expr('SUM(num_replies)', 'total_replies')
@@ -602,7 +602,7 @@ function update_forum($forum_id)
602602

603603
$select_update_forum = array('last_post', 'last_post_id', 'last_poster');
604604

605-
$result = \ORM::for_table('topics')->select_many($select_update_forum)
605+
$result = \DB::for_table('topics')->select_many($select_update_forum)
606606
->where('forum_id', $forum_id)
607607
->where_null('moved_to')
608608
->order_by_desc('last_post')
@@ -627,7 +627,7 @@ function update_forum($forum_id)
627627
'last_poster' => 'NULL',
628628
);
629629
}
630-
\ORM::for_table('forums')
630+
\DB::for_table('forums')
631631
->where('id', $forum_id)
632632
->find_one()
633633
->set($insert_update_forum)
@@ -667,17 +667,17 @@ function delete_topic($topic_id)
667667
array('moved_to' => $topic_id)
668668
);
669669

670-
\ORM::for_table('topics')
670+
\DB::for_table('topics')
671671
->where_any_is($where_delete_topic)
672672
->delete_many();
673673

674674
// Delete posts in topic
675-
\ORM::for_table('posts')
675+
\DB::for_table('posts')
676676
->where('topic_id', $topic_id)
677677
->delete_many();
678678

679679
// Delete any subscriptions for this topic
680-
\ORM::for_table('topic_subscriptions')
680+
\DB::for_table('topic_subscriptions')
681681
->where('topic_id', $topic_id)
682682
->delete_many();
683683
}
@@ -691,7 +691,7 @@ function delete_post($post_id, $topic_id)
691691
// Get Slim current session
692692
$feather = \Slim\Slim::getInstance();
693693

694-
$result = \ORM::for_table('posts')
694+
$result = \DB::for_table('posts')
695695
->select_many('id', 'poster', 'posted')
696696
->where('topic_id', $topic_id)
697697
->order_by_desc('id')
@@ -712,15 +712,15 @@ function delete_post($post_id, $topic_id)
712712
}
713713

714714
// Delete the post
715-
\ORM::for_table('posts')
715+
\DB::for_table('posts')
716716
->where('id', $post_id)
717717
->find_one()
718718
->delete();
719719

720720
strip_search_index($post_id);
721721

722722
// Count number of replies in the topic
723-
$num_replies = \ORM::for_table('posts')->where('topic_id', $topic_id)->count() - 1;
723+
$num_replies = \DB::for_table('posts')->where('topic_id', $topic_id)->count() - 1;
724724

725725
// If the message we deleted is the most recent in the topic (at the end of the topic)
726726
if ($last_id == $post_id) {
@@ -732,14 +732,14 @@ function delete_post($post_id, $topic_id)
732732
'last_poster' => $second_poster,
733733
'num_replies' => $num_replies,
734734
);
735-
\ORM::for_table('topics')
735+
\DB::for_table('topics')
736736
->where('id', $topic_id)
737737
->find_one()
738738
->set($update_topic)
739739
->save();
740740
} else {
741741
// We deleted the only reply, so now last_post/last_post_id/last_poster is posted/id/poster from the topic itself
742-
\ORM::for_table('topics')
742+
\DB::for_table('topics')
743743
->where('id', $topic_id)
744744
->find_one()
745745
->set_expr('last_post', 'posted')
@@ -750,7 +750,7 @@ function delete_post($post_id, $topic_id)
750750
}
751751
} else {
752752
// Otherwise we just decrement the reply counter
753-
\ORM::for_table('topics')
753+
\DB::for_table('topics')
754754
->where('id', $topic_id)
755755
->find_one()
756756
->set('num_replies', $num_replies)
@@ -1727,10 +1727,10 @@ function display_saved_queries()
17271727

17281728
$query_time_total = 0.0;
17291729
$i = 0;
1730-
foreach (\ORM::get_query_log()[1] as $query) {
1730+
foreach (\DB::get_query_log()[1] as $query) {
17311731
?>
17321732
<tr>
1733-
<td class="tcl"><?php echo feather_escape(round(\ORM::get_query_log()[0][$i], 6)) ?></td>
1733+
<td class="tcl"><?php echo feather_escape(round(\DB::get_query_log()[0][$i], 6)) ?></td>
17341734
<td class="tcr"><?php echo feather_escape($query) ?></td>
17351735
</tr>
17361736
<?php

0 commit comments

Comments
 (0)