Welcome Guest, Not a member yet? Register   Sign In
DataMapper ORM v1.8.1

[eluser]WanWizard[/eluser]
id is your primary key, so it's always non zero?

[eluser]tarciozemel[/eluser]
[quote author="WanWizard" date="1330116585"]id is your primary key, so it's always non zero?[/quote]

In this case I have a really messed DB, but the field could be anything else.

Code:
$c = new Company();
$c->where_related('segment', 'foo <>', 0)->get_iterated();

It's possible do something like this?

[eluser]WanWizard[/eluser]
Yeah, that works as advertised.

If not, do a c$->last_query() and check what goes wrong.

[eluser]tarciozemel[/eluser]
[quote author="WanWizard" date="1330170207"]Yeah, that works as advertised.

If not, do a c$->last_query() and check what goes wrong.[/quote]

The problem is: although I use
Code:
$c->where_related('segment', 'foo <>', 0)->get_iterated();

the generated query don't have the "<>" operator; seems like DM excludes that. So the generated query uses

Code:
foo = 0

[eluser]John Murowaniecki[/eluser]
Code:
'<>' == '!=' ? 'I know that less than or greater than is used for numeric comparison but it works fine for that, not?' : 'Sorry, but my mind is filled with trash and I need to empty..'

[eluser]WanWizard[/eluser]
lol.

You indeed need "!=", and not "<>"...

[eluser]tarciozemel[/eluser]
[quote author="WanWizard" date="1330381497"]
You indeed need "!=", and not "<>"...[/quote]

Same result using "!="... Any ideas?

[eluser]John Murowaniecki[/eluser]
I think the rule is to use <=> to compare numbers, dates and values and measurable !=, = for text and other information (texts). From what I tested here <> and != had the same result using int and varchar fields data.. I believe it is only a convention, a model, a pattern, but I don't think its necessary to closely used in this way - since we can use != to validate numerical values ​​as well.

The same behavior was float and text field data - tested with small numbers (I don't know how it behaves with large numbers, also I doubt my ability to make a test - or series of tests - to validate this theory).

In short: despite having different purposes '!=' and '<>' showed the same results.

Acredito que a regra seja utilizar <=> para comparações entre números, datas e valores mensuráveis e !=, = para textos e outras informações (textos). Pelo que testei aqui '<>' e '!=' tiveram o mesmo resultado utilizando campos int e varchar.. Acredito que seja apenas uma convenção, um modelo, um padrão, mas não creio que seja estreitamente necessário utilizar dessa forma - visto que podemos utilizar != para validar valores numéricos também.

O mesmo comportamento teve float e text - porém efetuei testes com números pequenos (não sei como se comportaria com números grandes, igualmente duvido da minha capacidade de efetuar um teste - ou série de testes - que validem essa teoria).

Resumindo: apesar de terem propósitos diferentes '!=' e '<>' apresentaram os mesmos resultados.



P.S.: I wrote in brazilian native language 'cos I believe I wasn't cleary enough. Escrevi em brasileño pois creio não ter sido suficientemente claro.

This sugar melts my brain..

[eluser]tarciozemel[/eluser]
[quote author="John Murowaniecki" date="1330440901"]I think the rule is to use <=> to compare numbers, dates and values and measurable !=, = for text and other information (texts). From what I tested here <> and != had the same result using int and varchar fields data.. I believe it is only a convention, a model, a pattern, but I don't think its necessary to closely used in this way - since we can use != to validate numerical values ​​as well.

The same behavior was float and text field data - tested with small numbers (I don't know how it behaves with large numbers, also I doubt my ability to make a test - or series of tests - to validate this theory).

In short: despite having different purposes '!=' and '<>' showed the same results.

Acredito que a regra seja utilizar <=> para comparações entre números, datas e valores mensuráveis e !=, = para textos e outras informações (textos). Pelo que testei aqui '<>' e '!=' tiveram o mesmo resultado utilizando campos int e varchar.. Acredito que seja apenas uma convenção, um modelo, um padrão, mas não creio que seja estreitamente necessário utilizar dessa forma - visto que podemos utilizar != para validar valores numéricos também.

O mesmo comportamento teve float e text - porém efetuei testes com números pequenos (não sei como se comportaria com números grandes, igualmente duvido da minha capacidade de efetuar um teste - ou série de testes - que validem essa teoria).

Resumindo: apesar de terem propósitos diferentes '!=' e '<>' apresentaram os mesmos resultados.



P.S.: I wrote in brazilian native language 'cos I believe I wasn't cleary enough. Escrevi em brasileño pois creio não ter sido suficientemente claro.

This sugar melts my brain..[/quote]

Seem like the problem is not the operator, but DM removing any kind of stuff in that sintax, always using the "="...

Anyway, I did it using

Code:
where_not_in_related('segment', 'foo', 0);

But I don't know about the performance of this... Anyhow, thanks!

PS: Legal você saber escrever em "brasileño"! ;-)

[eluser]WanWizard[/eluser]
DM doesn't do anything, it passes the where() clasue as-is to CI's internal $this->db->where().




Theme © iAndrew 2016 - Forum software by © MyBB