Eloquent receive a value like a column name?How to Sort Multi-dimensional Array by Value?PHP array delete by value (not key)Laravel 4 Eloquent Query Using WHERE with OR AND OR?Add a custom attribute to a Laravel / Eloquent model on load?How to Create Multiple Where Clause Query Using Laravel Eloquent?Get Specific Columns Using “With()” Function in Laravel EloquentGet the Last Inserted Id Using Laravel EloquentTrying to aggregate column values in eloquentEloquent ORM: Complex left join insists on using value as column nameEloquent - How to use alias name in further multiple conditions?
Is it safe to redirect stdout and stderr to the same file without file descriptor copies?
Python script to extract text from PDF with images
What is Orcus doing with Mind Flayers in the art on the last page of Volo's Guide to Monsters?
Moons and messages
How would a developer who mostly fixed bugs for years at a company call out their contributions in their CV?
Comparison of bool data types in C++
Knight's Tour on a 7x7 Board starting from D5
Are cells guaranteed to get at least one mitochondrion when they divide?
Would cybernetic implants allow humans to use biofeedback to boost their performance to superhuman levels? If so how far could we take it?
Why do the i8080 I/O instructions take a byte-sized operand to determine the port?
How did the Allies achieve air superiority on Sicily?
Goldfish unresponsive, what should I do?
Split into three!
How does Dreadhorde Arcanist interact with split cards?
Writing "hahaha" versus describing the laugh
Unary Enumeration
EU rights when flight delayed so much that return is missed
Are there historical examples of audiences drawn to a work that was "so bad it's good"?
Why did other houses not demand this?
Could a rotating ring space station have a bolo-like extension?
Piping the output of comand columns
Why is unzipped directory exactly 4.0K (much smaller than zipped file)?
Negative impact of having the launch pad away from the Equator
Prince of Darkness goes cryptic
Eloquent receive a value like a column name?
How to Sort Multi-dimensional Array by Value?PHP array delete by value (not key)Laravel 4 Eloquent Query Using WHERE with OR AND OR?Add a custom attribute to a Laravel / Eloquent model on load?How to Create Multiple Where Clause Query Using Laravel Eloquent?Get Specific Columns Using “With()” Function in Laravel EloquentGet the Last Inserted Id Using Laravel EloquentTrying to aggregate column values in eloquentEloquent ORM: Complex left join insists on using value as column nameEloquent - How to use alias name in further multiple conditions?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I have the follow model in Laravel Eloquent
:
<?php
namespace SacModels;
use IlluminateDatabaseEloquentModel as Eloquent;
class PatientsDevices extends Eloquent
...
public static function getDevicesByDateTime()
$currrentDateTime = (new DateTime('now', new DateTimeZone('America/Costa_Rica')))->format('Y-m-d H:i:s');
return self::where('monitor', '=', 1)
->whereBetween($currrentDateTime, ['start_date_time', 'end_date_time'])
->get();
...
With this, I try to build the next SQL sentence:
SELECT *
FROM `patients_devices`
WHERE
(
`monitor` = 1 AND
'2019-03-23 13:11:48' BETWEEN `start_date_time` AND `end_date_time`
)
But instead Eloquent build:
SELECT *
FROM `patients_devices`
WHERE
(
`monitor` = 1 AND
`2019-03-23 13:11:48` BETWEEN `start_date_time` AND `end_date_time`
)
The little big difference are (') and (`) (backquote/backtick) into where condition, since the first is recognized as string but the second like a literal column name.
In my model, I have a public method that get retrive to data collection with theses conditions: the monitor value is 1 and
a timestamp exists between two datetime columns (start and end).
My problem: I'm forced in use models, and I see that I use of whereBetween
method, recognize $currrentDateTime
like as column when should recognize as value, since in SQL I can use columns and values positions on the clause where whitout restrincts.
This is a Eloquent
limitation? or I'm developing of wrong way the logic SQL?. I can resolve it the other way using models?
php laravel-5 orm eloquent mariadb
add a comment |
I have the follow model in Laravel Eloquent
:
<?php
namespace SacModels;
use IlluminateDatabaseEloquentModel as Eloquent;
class PatientsDevices extends Eloquent
...
public static function getDevicesByDateTime()
$currrentDateTime = (new DateTime('now', new DateTimeZone('America/Costa_Rica')))->format('Y-m-d H:i:s');
return self::where('monitor', '=', 1)
->whereBetween($currrentDateTime, ['start_date_time', 'end_date_time'])
->get();
...
With this, I try to build the next SQL sentence:
SELECT *
FROM `patients_devices`
WHERE
(
`monitor` = 1 AND
'2019-03-23 13:11:48' BETWEEN `start_date_time` AND `end_date_time`
)
But instead Eloquent build:
SELECT *
FROM `patients_devices`
WHERE
(
`monitor` = 1 AND
`2019-03-23 13:11:48` BETWEEN `start_date_time` AND `end_date_time`
)
The little big difference are (') and (`) (backquote/backtick) into where condition, since the first is recognized as string but the second like a literal column name.
In my model, I have a public method that get retrive to data collection with theses conditions: the monitor value is 1 and
a timestamp exists between two datetime columns (start and end).
My problem: I'm forced in use models, and I see that I use of whereBetween
method, recognize $currrentDateTime
like as column when should recognize as value, since in SQL I can use columns and values positions on the clause where whitout restrincts.
This is a Eloquent
limitation? or I'm developing of wrong way the logic SQL?. I can resolve it the other way using models?
php laravel-5 orm eloquent mariadb
add a comment |
I have the follow model in Laravel Eloquent
:
<?php
namespace SacModels;
use IlluminateDatabaseEloquentModel as Eloquent;
class PatientsDevices extends Eloquent
...
public static function getDevicesByDateTime()
$currrentDateTime = (new DateTime('now', new DateTimeZone('America/Costa_Rica')))->format('Y-m-d H:i:s');
return self::where('monitor', '=', 1)
->whereBetween($currrentDateTime, ['start_date_time', 'end_date_time'])
->get();
...
With this, I try to build the next SQL sentence:
SELECT *
FROM `patients_devices`
WHERE
(
`monitor` = 1 AND
'2019-03-23 13:11:48' BETWEEN `start_date_time` AND `end_date_time`
)
But instead Eloquent build:
SELECT *
FROM `patients_devices`
WHERE
(
`monitor` = 1 AND
`2019-03-23 13:11:48` BETWEEN `start_date_time` AND `end_date_time`
)
The little big difference are (') and (`) (backquote/backtick) into where condition, since the first is recognized as string but the second like a literal column name.
In my model, I have a public method that get retrive to data collection with theses conditions: the monitor value is 1 and
a timestamp exists between two datetime columns (start and end).
My problem: I'm forced in use models, and I see that I use of whereBetween
method, recognize $currrentDateTime
like as column when should recognize as value, since in SQL I can use columns and values positions on the clause where whitout restrincts.
This is a Eloquent
limitation? or I'm developing of wrong way the logic SQL?. I can resolve it the other way using models?
php laravel-5 orm eloquent mariadb
I have the follow model in Laravel Eloquent
:
<?php
namespace SacModels;
use IlluminateDatabaseEloquentModel as Eloquent;
class PatientsDevices extends Eloquent
...
public static function getDevicesByDateTime()
$currrentDateTime = (new DateTime('now', new DateTimeZone('America/Costa_Rica')))->format('Y-m-d H:i:s');
return self::where('monitor', '=', 1)
->whereBetween($currrentDateTime, ['start_date_time', 'end_date_time'])
->get();
...
With this, I try to build the next SQL sentence:
SELECT *
FROM `patients_devices`
WHERE
(
`monitor` = 1 AND
'2019-03-23 13:11:48' BETWEEN `start_date_time` AND `end_date_time`
)
But instead Eloquent build:
SELECT *
FROM `patients_devices`
WHERE
(
`monitor` = 1 AND
`2019-03-23 13:11:48` BETWEEN `start_date_time` AND `end_date_time`
)
The little big difference are (') and (`) (backquote/backtick) into where condition, since the first is recognized as string but the second like a literal column name.
In my model, I have a public method that get retrive to data collection with theses conditions: the monitor value is 1 and
a timestamp exists between two datetime columns (start and end).
My problem: I'm forced in use models, and I see that I use of whereBetween
method, recognize $currrentDateTime
like as column when should recognize as value, since in SQL I can use columns and values positions on the clause where whitout restrincts.
This is a Eloquent
limitation? or I'm developing of wrong way the logic SQL?. I can resolve it the other way using models?
php laravel-5 orm eloquent mariadb
php laravel-5 orm eloquent mariadb
edited Mar 23 at 22:03
Ale
asked Mar 23 at 21:54
AleAle
272313
272313
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Don't you want to get the entries in between these dates?
self::where('monitor', '=', 1)
->where('start_date_time', '<=', $currentDateTime)
->where('end_date_time', '>=', $currentDateTime)
->get();
If you want to use whereBetween()
, the syntax is ->whereBetween('column', [values])
, so I doubt it fits in your case.
Thanks @senty, is you right about of the documentation, the first param is a column name, so I supposed I could pass a value like a column name. You code work.
– Ale
Mar 23 at 22:11
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318753%2feloquent-receive-a-value-like-a-column-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Don't you want to get the entries in between these dates?
self::where('monitor', '=', 1)
->where('start_date_time', '<=', $currentDateTime)
->where('end_date_time', '>=', $currentDateTime)
->get();
If you want to use whereBetween()
, the syntax is ->whereBetween('column', [values])
, so I doubt it fits in your case.
Thanks @senty, is you right about of the documentation, the first param is a column name, so I supposed I could pass a value like a column name. You code work.
– Ale
Mar 23 at 22:11
add a comment |
Don't you want to get the entries in between these dates?
self::where('monitor', '=', 1)
->where('start_date_time', '<=', $currentDateTime)
->where('end_date_time', '>=', $currentDateTime)
->get();
If you want to use whereBetween()
, the syntax is ->whereBetween('column', [values])
, so I doubt it fits in your case.
Thanks @senty, is you right about of the documentation, the first param is a column name, so I supposed I could pass a value like a column name. You code work.
– Ale
Mar 23 at 22:11
add a comment |
Don't you want to get the entries in between these dates?
self::where('monitor', '=', 1)
->where('start_date_time', '<=', $currentDateTime)
->where('end_date_time', '>=', $currentDateTime)
->get();
If you want to use whereBetween()
, the syntax is ->whereBetween('column', [values])
, so I doubt it fits in your case.
Don't you want to get the entries in between these dates?
self::where('monitor', '=', 1)
->where('start_date_time', '<=', $currentDateTime)
->where('end_date_time', '>=', $currentDateTime)
->get();
If you want to use whereBetween()
, the syntax is ->whereBetween('column', [values])
, so I doubt it fits in your case.
answered Mar 23 at 22:03
sentysenty
4,150758141
4,150758141
Thanks @senty, is you right about of the documentation, the first param is a column name, so I supposed I could pass a value like a column name. You code work.
– Ale
Mar 23 at 22:11
add a comment |
Thanks @senty, is you right about of the documentation, the first param is a column name, so I supposed I could pass a value like a column name. You code work.
– Ale
Mar 23 at 22:11
Thanks @senty, is you right about of the documentation, the first param is a column name, so I supposed I could pass a value like a column name. You code work.
– Ale
Mar 23 at 22:11
Thanks @senty, is you right about of the documentation, the first param is a column name, so I supposed I could pass a value like a column name. You code work.
– Ale
Mar 23 at 22:11
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55318753%2feloquent-receive-a-value-like-a-column-name%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown