SELECT id,
(SELECT COUNT(id) FROM table1 WHERE model_id = t1.id) as 'Таблица №1',
(SELECT COUNT(id) FROM table2 WHERE model_id = t1.id) as 'Таблица №2'
FROM table1 as t1
WHERE id = 781;
public static function getList()
{
return static::find()
->select(['name', 'id'])
->indexBy('id')
->asArray()
->column();
}
/** @var LanguageManager $languageManager */
$languageManager = Yii::$app->languageManager;
class Yii extends \yii\BaseYii
{
/**
* @var BaseApplication|WebApplication|ConsoleApplication
*/
public static $app;
}
/**
* @property backend\components\bootstrap\SectionTreeManager $sectionTreeManager
* @property backend\components\constructor\Component $constructor
* @property backend\components\rbac\SystemAuthManager $systemAuthManager
* @property backend\components\rbac\UserAuthManager $userAuthManager
* @property common\components\language\LanguageManager $languageManager
* @property common\components\view\ViewBlockManager $viewBlock
*/
abstract class BaseApplication extends \yii\base\Application {}
/**
* @property backend\components\bootstrap\SectionTreeManager $sectionTreeManager
* @property backend\components\constructor\Component $constructor
* @property backend\components\rbac\SystemAuthManager $systemAuthManager
* @property backend\components\rbac\UserAuthManager $userAuthManager
* @property common\components\language\LanguageManager $languageManager
* @property common\components\view\ViewBlockManager $viewBlock
*/
class WebApplication extends \yii\web\Application {}
/**
* @property backend\components\bootstrap\SectionTreeManager $sectionTreeManager
* @property backend\components\constructor\Component $constructor
* @property backend\components\rbac\SystemAuthManager $systemAuthManager
* @property backend\components\rbac\UserAuthManager $userAuthManager
* @property common\components\language\LanguageManager $languageManager
* @property common\components\view\ViewBlockManager $viewBlock
*/
class ConsoleApplication extends \yii\console\Application {}
// return all customers in an array indexed by customer IDs
// SELECT * FROM `customer`
$customers = Customer::find()
->indexBy('id')
->all();
$.ajax({
url: 'URL',
dataType: "JSON",
method: "POST",
data: {
var1: arg1,
},
statusCode: {
200: function() {
if (console!==undefined) console.log('Request send but not data not parsed yet!'); // то что тебе надо
},
500: function() {
if (console!==undefined) console.log('Server error 500!');
},
404: function() {
if (console!==undefined) console.log('Server error 404!');
}
},
success: function(data) {
if (console!==undefined) console.log(data);
},
error: function(v1,v2,v3) {
if (console!==undefined) console.log(v1,v2,v3);
}
});
If there is already a header with the same name, the new one will be appended to it instead of replacing it.
var s = document.createElement('script');
s.src = '/script.js'; // путь до нужного скрипта
s.async = true;
s.onload = s.onreadystatechange = function() {} // функция сработает сразу после загрузки скрипта
document.head.appendChild(s);