phalcon phql find query with array element in where
up vote
0
down vote
favorite
i am using phalcon's find query,
and using an array element in the where clause, but getting an error
"'Scanning error before '3] > :from_time:...' when parsing: SELECT..."
i have a work around, not using phalcon's find, but want to figure this out, how to use an array element in where clause, any idea would be welcome.
Thanks, Tal
phalcon (version 3.4.1)
PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit
use PhalconMvcModel;
class Products extends Model
{
public function initialize()
{
$this->setSource("products");
}
public function findByIdAndTime($id, $from_time)
{
$result = Products::find(["id=:id: AND create_time[3] > :from_time:",
['id' => $Id,'from_time' => $from_time]]);
return $result;
}
}
use example:
try
{
$products = new Products();
$products->findByIdAndTime(1, 1541672000);
}
catch(Exception $e)
{
var_dump($e->getMessage());
}
the postgre DB table column create_time is of type integer (in example {1541600807,0,1541673916}), and the value of $from_time is a previously inserted now_time() from the DB (1541672000 in example)
here is how to create the table
CREATE TABLE public.products
(
id int,
create_time int
);
INSERT INTO products(create_time) VALUES ('{1541600807,0,1541673916}');
php find phalcon
add a comment |
up vote
0
down vote
favorite
i am using phalcon's find query,
and using an array element in the where clause, but getting an error
"'Scanning error before '3] > :from_time:...' when parsing: SELECT..."
i have a work around, not using phalcon's find, but want to figure this out, how to use an array element in where clause, any idea would be welcome.
Thanks, Tal
phalcon (version 3.4.1)
PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit
use PhalconMvcModel;
class Products extends Model
{
public function initialize()
{
$this->setSource("products");
}
public function findByIdAndTime($id, $from_time)
{
$result = Products::find(["id=:id: AND create_time[3] > :from_time:",
['id' => $Id,'from_time' => $from_time]]);
return $result;
}
}
use example:
try
{
$products = new Products();
$products->findByIdAndTime(1, 1541672000);
}
catch(Exception $e)
{
var_dump($e->getMessage());
}
the postgre DB table column create_time is of type integer (in example {1541600807,0,1541673916}), and the value of $from_time is a previously inserted now_time() from the DB (1541672000 in example)
here is how to create the table
CREATE TABLE public.products
(
id int,
create_time int
);
INSERT INTO products(create_time) VALUES ('{1541600807,0,1541673916}');
php find phalcon
Where does$Id
come from? Where does$from_time
come from? Please read: How to create a Minimal, Complete, and Verifiable example. Without more infomation, it will be really hard to help you.
– Eugene Anisiutkin
Nov 8 at 9:31
What iscreate_time[3]
? This has to be your db column... What is the value of$from_time
– Nikolay Mihaylov
Nov 8 at 10:43
nikolay-mihaylov, the create_time column is of type integer (in example {1541600807,0,1541673916}), so i refer to the 3rd element in the array, and the value of $from_time is a previously inserted now_time() from the DB (1541675158 in example)
– Tal
Nov 8 at 11:04
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i am using phalcon's find query,
and using an array element in the where clause, but getting an error
"'Scanning error before '3] > :from_time:...' when parsing: SELECT..."
i have a work around, not using phalcon's find, but want to figure this out, how to use an array element in where clause, any idea would be welcome.
Thanks, Tal
phalcon (version 3.4.1)
PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit
use PhalconMvcModel;
class Products extends Model
{
public function initialize()
{
$this->setSource("products");
}
public function findByIdAndTime($id, $from_time)
{
$result = Products::find(["id=:id: AND create_time[3] > :from_time:",
['id' => $Id,'from_time' => $from_time]]);
return $result;
}
}
use example:
try
{
$products = new Products();
$products->findByIdAndTime(1, 1541672000);
}
catch(Exception $e)
{
var_dump($e->getMessage());
}
the postgre DB table column create_time is of type integer (in example {1541600807,0,1541673916}), and the value of $from_time is a previously inserted now_time() from the DB (1541672000 in example)
here is how to create the table
CREATE TABLE public.products
(
id int,
create_time int
);
INSERT INTO products(create_time) VALUES ('{1541600807,0,1541673916}');
php find phalcon
i am using phalcon's find query,
and using an array element in the where clause, but getting an error
"'Scanning error before '3] > :from_time:...' when parsing: SELECT..."
i have a work around, not using phalcon's find, but want to figure this out, how to use an array element in where clause, any idea would be welcome.
Thanks, Tal
phalcon (version 3.4.1)
PostgreSQL 9.6.6 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.3 20140911 (Red Hat 4.8.3-9), 64-bit
use PhalconMvcModel;
class Products extends Model
{
public function initialize()
{
$this->setSource("products");
}
public function findByIdAndTime($id, $from_time)
{
$result = Products::find(["id=:id: AND create_time[3] > :from_time:",
['id' => $Id,'from_time' => $from_time]]);
return $result;
}
}
use example:
try
{
$products = new Products();
$products->findByIdAndTime(1, 1541672000);
}
catch(Exception $e)
{
var_dump($e->getMessage());
}
the postgre DB table column create_time is of type integer (in example {1541600807,0,1541673916}), and the value of $from_time is a previously inserted now_time() from the DB (1541672000 in example)
here is how to create the table
CREATE TABLE public.products
(
id int,
create_time int
);
INSERT INTO products(create_time) VALUES ('{1541600807,0,1541673916}');
php find phalcon
php find phalcon
edited Nov 8 at 12:23
asked Nov 8 at 9:22
Tal
117
117
Where does$Id
come from? Where does$from_time
come from? Please read: How to create a Minimal, Complete, and Verifiable example. Without more infomation, it will be really hard to help you.
– Eugene Anisiutkin
Nov 8 at 9:31
What iscreate_time[3]
? This has to be your db column... What is the value of$from_time
– Nikolay Mihaylov
Nov 8 at 10:43
nikolay-mihaylov, the create_time column is of type integer (in example {1541600807,0,1541673916}), so i refer to the 3rd element in the array, and the value of $from_time is a previously inserted now_time() from the DB (1541675158 in example)
– Tal
Nov 8 at 11:04
add a comment |
Where does$Id
come from? Where does$from_time
come from? Please read: How to create a Minimal, Complete, and Verifiable example. Without more infomation, it will be really hard to help you.
– Eugene Anisiutkin
Nov 8 at 9:31
What iscreate_time[3]
? This has to be your db column... What is the value of$from_time
– Nikolay Mihaylov
Nov 8 at 10:43
nikolay-mihaylov, the create_time column is of type integer (in example {1541600807,0,1541673916}), so i refer to the 3rd element in the array, and the value of $from_time is a previously inserted now_time() from the DB (1541675158 in example)
– Tal
Nov 8 at 11:04
Where does
$Id
come from? Where does $from_time
come from? Please read: How to create a Minimal, Complete, and Verifiable example. Without more infomation, it will be really hard to help you.– Eugene Anisiutkin
Nov 8 at 9:31
Where does
$Id
come from? Where does $from_time
come from? Please read: How to create a Minimal, Complete, and Verifiable example. Without more infomation, it will be really hard to help you.– Eugene Anisiutkin
Nov 8 at 9:31
What is
create_time[3]
? This has to be your db column... What is the value of $from_time
– Nikolay Mihaylov
Nov 8 at 10:43
What is
create_time[3]
? This has to be your db column... What is the value of $from_time
– Nikolay Mihaylov
Nov 8 at 10:43
nikolay-mihaylov, the create_time column is of type integer (in example {1541600807,0,1541673916}), so i refer to the 3rd element in the array, and the value of $from_time is a previously inserted now_time() from the DB (1541675158 in example)
– Tal
Nov 8 at 11:04
nikolay-mihaylov, the create_time column is of type integer (in example {1541600807,0,1541673916}), so i refer to the 3rd element in the array, and the value of $from_time is a previously inserted now_time() from the DB (1541675158 in example)
– Tal
Nov 8 at 11:04
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
Try this
public function findByIdAndTime($id, $from_time)
{
$result = Products::find([
'conditions' => 'id= :id: AND create_time[3] > :from_time:',
'bind' => [
'id' => $id,
'from_time' => $from_time
]
]);
return $result;
}
same error "'Scanning error before '3] > :from_time:...' when parsing: SELECT...", but nice idea, thanks.
– Tal
Nov 11 at 7:40
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
Try this
public function findByIdAndTime($id, $from_time)
{
$result = Products::find([
'conditions' => 'id= :id: AND create_time[3] > :from_time:',
'bind' => [
'id' => $id,
'from_time' => $from_time
]
]);
return $result;
}
same error "'Scanning error before '3] > :from_time:...' when parsing: SELECT...", but nice idea, thanks.
– Tal
Nov 11 at 7:40
add a comment |
up vote
0
down vote
Try this
public function findByIdAndTime($id, $from_time)
{
$result = Products::find([
'conditions' => 'id= :id: AND create_time[3] > :from_time:',
'bind' => [
'id' => $id,
'from_time' => $from_time
]
]);
return $result;
}
same error "'Scanning error before '3] > :from_time:...' when parsing: SELECT...", but nice idea, thanks.
– Tal
Nov 11 at 7:40
add a comment |
up vote
0
down vote
up vote
0
down vote
Try this
public function findByIdAndTime($id, $from_time)
{
$result = Products::find([
'conditions' => 'id= :id: AND create_time[3] > :from_time:',
'bind' => [
'id' => $id,
'from_time' => $from_time
]
]);
return $result;
}
Try this
public function findByIdAndTime($id, $from_time)
{
$result = Products::find([
'conditions' => 'id= :id: AND create_time[3] > :from_time:',
'bind' => [
'id' => $id,
'from_time' => $from_time
]
]);
return $result;
}
answered Nov 9 at 14:05
Yaroslaw
684
684
same error "'Scanning error before '3] > :from_time:...' when parsing: SELECT...", but nice idea, thanks.
– Tal
Nov 11 at 7:40
add a comment |
same error "'Scanning error before '3] > :from_time:...' when parsing: SELECT...", but nice idea, thanks.
– Tal
Nov 11 at 7:40
same error "'Scanning error before '3] > :from_time:...' when parsing: SELECT...", but nice idea, thanks.
– Tal
Nov 11 at 7:40
same error "'Scanning error before '3] > :from_time:...' when parsing: SELECT...", but nice idea, thanks.
– Tal
Nov 11 at 7:40
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f53204723%2fphalcon-phql-find-query-with-array-element-in-where%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
Where does
$Id
come from? Where does$from_time
come from? Please read: How to create a Minimal, Complete, and Verifiable example. Without more infomation, it will be really hard to help you.– Eugene Anisiutkin
Nov 8 at 9:31
What is
create_time[3]
? This has to be your db column... What is the value of$from_time
– Nikolay Mihaylov
Nov 8 at 10:43
nikolay-mihaylov, the create_time column is of type integer (in example {1541600807,0,1541673916}), so i refer to the 3rd element in the array, and the value of $from_time is a previously inserted now_time() from the DB (1541675158 in example)
– Tal
Nov 8 at 11:04