May be a bug in the server script !
May be a bug in the server script !

I want to limit the elements of a list of 'vDevisPrestation' table with the WHERE instruction with "vDevis_id=70".
Here is the PHP script and the request sent to the database obtained with the option -> debug ('true')
$out = Editor::inst( $db, 'vDevisLigne' )
->debug( true )
->fields(
Field::inst( 'vDevisLigne.id' )->set(false),
Field::inst( 'vDevisLigne.vDevisPrestation_id' )
->options( Options::inst()
->table('vDevisPrestation')
->value('id')
->label('prestation')
->where('vDevis_id',70,'=')
)
->validator( Validate::dbValues() ),
Field::inst( 'vDevisLigne.Libelle' ),
...
in the returned json, the query is :
{"query":"SELECT DISTINCT [id] as 'id', [prestation] as 'prestation' FROM [vDevisPrestation] WHERE [vDevis_id] IS NULL ","bindings":[]}.
it sould be :
{"query":"SELECT DISTINCT [id] as 'id', [prestation] as 'prestation' FROM [vDevisPrestation] WHERE [vDevis_id] = 70 ","bindings":[]}.
My table definition is :
vDevisPrestation
* id
* prestation
* vDevis_id
What can i do ?
Another question : Is it possible to combinate (concatenate) two feilds in the label ('prestation' and 'vDevis_id' for exemple) ?
This question has accepted answers - jump to:
Answers
Yes. You can pass an array to the
label()
method. It will concatenate the values using a space character by default. If that doesn't suit, then there is also arender()
method for theOptions
class that you can use to modify the label.Try:
As the documentation notes the
Options->where()
method takes a function, not a list of parameters.Regards,
Allan
Thank you for your reply
With your response and documentation, I understand the use of a closure function on options.
But if I replace 70 with a variable $vDevis_id. I have the following return: "error": "Undefined variable: vDevis_id"
$vDevis_id is well defined. The value is successfully used in the wher contition for 'vDevisLigne' table.
This is certainly a variable scope problem, but I do not see how to solve it.
Correct - with PHP closure functions you have you use a
use
statement - see the PHP documentation.In this case:
That's just how PHP works.
Allan
Thank you very much!