本文整理汇总了PHP中MainWP_DB::num_rows方法的典型用法代码示例。如果您正苦于以下问题:PHP MainWP_DB::num_rows方法的具体用法?PHP MainWP_DB::num_rows怎么用?PHP MainWP_DB::num_rows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainWP_DB
的用法示例。
在下文中一共展示了MainWP_DB::num_rows方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sync
public function sync($args, $assoc_args)
{
$websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser());
WP_CLI::line('Syncing ' . MainWP_DB::num_rows($websites) . ' sites');
$warnings = 0;
$errors = 0;
while ($websites && ($website = @MainWP_DB::fetch_object($websites))) {
WP_CLI::line(' -> ' . $website->name . ' (' . $website->url . ')');
try {
if (MainWP_Sync::syncSite($website)) {
WP_CLI::success(' Sync succeeded');
} else {
WP_CLI::warning(' Sync failed');
$warnings++;
}
} catch (Exception $e) {
WP_CLI::error(' Sync failed');
$errors++;
}
}
@MainWP_DB::free_result($websites);
if ($errors > 0) {
WP_CLI::error('Sync completed with errors');
} else {
if ($warnings > 0) {
WP_CLI::warning('Sync completed with warnings');
} else {
WP_CLI::success('Sync completed');
}
}
}
示例2: prepare_items
//.........这里部分代码省略.........
WHEN ((pluginConflicts <> "[]") AND (pluginConflicts IS NOT NULL) AND (pluginConflicts <> ""))
THEN 1
WHEN (offline_check_result = -1)
THEN 2
WHEN (wp_sync.sync_errors IS NOT NULL) AND (wp_sync.sync_errors <> "")
THEN 3
ELSE 4
+ (CASE plugin_upgrades WHEN "[]" THEN 0 ELSE 1 + LENGTH(plugin_upgrades) - LENGTH(REPLACE(plugin_upgrades, "\\"Name\\":", "\\"Name\\"")) END)
+ (CASE theme_upgrades WHEN "[]" THEN 0 ELSE 1 + LENGTH(theme_upgrades) - LENGTH(REPLACE(theme_upgrades, "\\"Name\\":", "\\"Name\\"")) END)
+ (CASE wp_upgrades WHEN "[]" THEN 0 ELSE 1 END)
END ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc');
} else {
if (isset($_REQUEST['orderby']) && $_REQUEST['orderby'] == 'last_post') {
$orderby = 'wp_sync.last_post_gmt ' . ($_GET['order'] == 'asc' ? 'asc' : 'desc');
}
}
}
}
}
}
$perPage = $this->get_items_per_page('mainwp_managesites_per_page');
$currentPage = $this->get_pagenum();
$no_request = !isset($_REQUEST['s']) && !isset($_REQUEST['g']) && !isset($_REQUEST['status']);
if (!isset($_REQUEST['status'])) {
if ($no_request) {
$_status = get_option('mainwp_managesites_filter_status');
if (!empty($_status)) {
$_REQUEST['status'] = $_status;
}
} else {
MainWP_Utility::update_option('mainwp_managesites_filter_status', '');
}
} else {
MainWP_Utility::update_option('mainwp_managesites_filter_status', $_REQUEST['status']);
}
if (!isset($_REQUEST['g'])) {
if ($no_request) {
$_g = get_option('mainwp_managesites_filter_group');
if (!empty($_g)) {
$_REQUEST['g'] = $_g;
}
} else {
MainWP_Utility::update_option('mainwp_managesites_filter_group', '');
}
} else {
MainWP_Utility::update_option('mainwp_managesites_filter_group', $_REQUEST['g']);
}
$where = null;
if (isset($_REQUEST['status']) && $_REQUEST['status'] != '') {
if ($_REQUEST['status'] == 'online') {
$where = 'wp.offline_check_result = 1';
} else {
if ($_REQUEST['status'] == 'offline') {
$where = 'wp.offline_check_result = -1';
} else {
if ($_REQUEST['status'] == 'disconnected') {
$where = 'wp_sync.sync_errors != ""';
} else {
if ($_REQUEST['status'] == 'update') {
$available_update_ids = $this->get_available_update_siteids();
if (empty($available_update_ids)) {
$where = 'wp.id = -1';
} else {
$where = 'wp.id IN (' . implode(',', $available_update_ids) . ') ';
}
}
}
}
}
}
if (isset($_REQUEST['g']) && $_REQUEST['g'] != '') {
$websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupId($_REQUEST['g'], true));
$totalRecords = $websites ? MainWP_DB::num_rows($websites) : 0;
if ($websites) {
@MainWP_DB::free_result($websites);
}
if (isset($_GET['orderby']) && $_GET['orderby'] == 'group') {
$orderby = 'wp.url';
}
$websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesByGroupId($_REQUEST['g'], true, $orderby, ($currentPage - 1) * $perPage, $perPage, $where));
} else {
if (isset($_REQUEST['status']) && $_REQUEST['status'] != '') {
$websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(true, null, $orderby, false, false, $where));
$totalRecords = $websites ? MainWP_DB::num_rows($websites) : 0;
if ($websites) {
@MainWP_DB::free_result($websites);
}
$websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(true, null, $orderby, ($currentPage - 1) * $perPage, $perPage, $where));
} else {
$websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(true, isset($_REQUEST['s']) && $_REQUEST['s'] != '' ? $_REQUEST['s'] : null, $orderby));
$totalRecords = $websites ? MainWP_DB::num_rows($websites) : 0;
if ($websites) {
@MainWP_DB::free_result($websites);
}
$websites = MainWP_DB::Instance()->query(MainWP_DB::Instance()->getSQLWebsitesForCurrentUser(true, isset($_REQUEST['s']) && $_REQUEST['s'] != '' ? $_REQUEST['s'] : null, $orderby, ($currentPage - 1) * $perPage, $perPage));
}
}
$this->set_pagination_args(array('total_items' => $totalRecords, 'per_page' => $perPage));
$this->items = $websites;
}
示例3: query
public function query($sql)
{
if ($sql == null) {
return false;
}
$result = @self::_query($sql, $this->wpdb->dbh);
if (!$result || @MainWP_DB::num_rows($result) == 0) {
return false;
}
return $result;
}