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}');









share|improve this question
























  • 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

















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}');









share|improve this question
























  • 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















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}');









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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




















  • 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


















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














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;
}





share|improve this answer





















  • same error "'Scanning error before '3] > :from_time:...' when parsing: SELECT...", but nice idea, thanks.
    – Tal
    Nov 11 at 7:40











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',
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
});


}
});














draft saved

draft discarded


















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

























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;
}





share|improve this answer





















  • same error "'Scanning error before '3] > :from_time:...' when parsing: SELECT...", but nice idea, thanks.
    – Tal
    Nov 11 at 7:40















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;
}





share|improve this answer





















  • same error "'Scanning error before '3] > :from_time:...' when parsing: SELECT...", but nice idea, thanks.
    – Tal
    Nov 11 at 7:40













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;
}





share|improve this answer












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;
}






share|improve this answer












share|improve this answer



share|improve this answer










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


















  • 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


















draft saved

draft discarded




















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini