我有简单但很长的查询,它计算结果的内容大约需要14秒.主表上的计数本身不到一秒钟,但在多次加入后,延迟太高,如下所示
Select Count(Distinct visits.id) As Count_id
From visits
Left Join clients_locations ON visits.client_location_id = clients_locations.id
Left Join clients ON clients_locations.client_id = clients.id
Left Join locations ON clients_locations.location_id = locations.id
Left Join users ON visits.user_id = users.id
Left Join potentialities ON clients_locations.potentiality = potentialities.id
Left Join classes ON clients_locations.class = classes.id
Left Join professions ON clients.profession_id = professions.id
Inner Join specialties ON clients.specialty_id = specialties.id
Left Join districts ON locations.district_id = districts.id
Left Join provinces ON districts.province_id = provinces.id
Left Join …Run Code Online (Sandbox Code Playgroud) 我希望在我的布局main.php页面上列出一些类别名称.由于布局没有任何关联的控制器或模型,我希望在类别模型上创建这样的静态方法:
public static function getHeaderModels()
{
// get all models here
return $models;
}
Run Code Online (Sandbox Code Playgroud)
然后在主要布局中
<?php
$models = Category::getHeaderModels();
foreach($models as $model)
{
// ....
}
?>
Run Code Online (Sandbox Code Playgroud)
我的问题是一个非常基本的问题: 如何从模型中检索这些类别名称?
这是完整的模型:
class Category extends CActiveRecord {
public static function model($className=__CLASS__) {
return parent::model($className);
}
public function tableName() {
return 'category';
}
public function rules() {
return array(
array('parent_id', 'numerical', 'integerOnly' => true),
array('name', 'length', 'max' => 255),
array('id, parent_id, name', 'safe', 'on' => 'search'),
);
}
public function relations() {
return …Run Code Online (Sandbox Code Playgroud) 来自google android studio的标准设置活动现在显示第一个标题"General".所以我修改了代码但是在第一次出现getPreferenceScreen()时我得到了java.lang.NullPointerException.addPreference(fakeHeader);
private void setupSimplePreferencesScreen() {
if (!isSimplePreferences(this)) {
return;
}
PreferenceCategory fakeHeader = new PreferenceCategory(this);
fakeHeader.setTitle(R.string.pref_header_notifications);
getPreferenceScreen().addPreference(fakeHeader);
addPreferencesFromResource(R.xml.pref_general);
fakeHeader = new PreferenceCategory(this);
fakeHeader.setTitle(R.string.pref_header_notifications);
getPreferenceScreen().addPreference(fakeHeader);
addPreferencesFromResource(R.xml.pref_notification);
bindPreferenceSummaryToValue(findPreference("username"));
bindPreferenceSummaryToValue(findPreference("password"));
bindPreferenceSummaryToValue(findPreference("server"));
}
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public void onBuildHeaders(List<Header> target) {
if (!isSimplePreferences(this)) {
loadHeadersFromResource(R.xml.pref_headers, target);
}
}
Run Code Online (Sandbox Code Playgroud)
<header
android:fragment="com.example.eslam.rottapharm.SettingsActivity$GeneralPreferenceFragment"
android:title="@string/pref_header_general" />
</preference-headers>
Run Code Online (Sandbox Code Playgroud) 什么是方言?
以及如何使用它并生成它?
IDE编辑器验证一直在讲述 "SQL dialect is not configured"
我用PHP + MySql和PhpStorm 8 IDE
我目前的AndroidManifest包含Sugar ORM声明如下
<application
android:name="com.orm.SugarApp"
Run Code Online (Sandbox Code Playgroud)
如他们在http://satyan.github.io/sugar/getting-started.html上的文档中所述.它包含在jar库中.
现在我需要为全局变量添加声明,如此处所示的 需要添加的Android全局变量
application android:name="MyApplication" android:icon="@drawable/icon" android:label="@string/app_name">
Run Code Online (Sandbox Code Playgroud)
到现有的申请部分.但这意味着两个应用程序部分或两个"android:name",这是完全错误的.如何实现这两个应用程序部分的场景