How can I write a query for ActiveRecord that will be analogous to findAllByPk function in yii?
I tried this:
$records = TableName::find($ids)->all();
But it does not work, returns all records.
If $ ids is an array, if primary keys are like [1, 3, 5, 23]. You can use this
[1, 3, 5, 23]
$entries = TableName::findAll($ids);
This is a short section for this syntax.
$entries = TableName::find() ->where(['id'=>$ids]) ->all();
Assuming what $idsis an array,
$ids
More examples in white papers .
Source: https://habr.com/ru/post/1544633/More articles:Rails: link_to with remote true and opening it in a new tab or window - ajaxID generation for managed user ID - c #SQL Server Query: Using JOIN to Include NULL Values - nullJitsi and ffplay - javaAngularJS: uncaught object due to service and module dependencies - angularjsJQuery open / close navigation - jqueryPerl: can't find object methods panel via package - perlHow to use gatekeeper with android client? - androidlist of standard concepts? - c ++дополнительная строка массива появляется из ниоткуда, используя каждую функцию - javascriptAll Articles