TYPO3 TCA select with own items - typo3

I use TYPO3 version 9.
I am trying to configure TCA selectMultipleSideBySide. I want to use without foreign table, I want to pass my own items. It displays correctly, but when I try to add more then 1 item, I get error:
These fields of record 3 in table "tx_scout24_domain_model_vehicle" have not been saved correctly: equipment! The values might have changed due to type casting of the database.
It because TYPO3 try to save data to main table, but not in mm table.
My current TCA:
'equipment' => array(
'label' => 'LLL:EXT:scout24/Resources/Private/Language/locallang_db.xlf:equipment',
'config' => array(
'type' => 'select',
'renderType' => 'selectMultipleSideBySide',
'items' => \Istar\Scout24\Service\FieldService::getFields('equipment'),
'MM' => 'tx_scout24_vehicle_equipment_mm',
),
),

According to the documentation the values are stored as comma-separated values. It is not possible to use a MM relation table. To store the values the columns must be of type varchar. Because you can store one value it seems that the type of your columns is an int, which can be stored without a problem.
So you have to do:
Remove the MM relation in your configuration
Change your table column to varchar

Related

In Laravel Backpack - Column data in view details and XLS download is truncated

If the column data has approximately more than 50 characters the column gets truncated at around 50.
addColumn function has 'type' => 'text'
In the end there is [...]
This is both in the details pop-up and XLS download.
Question is, can this limit be increased from any configuration?
Yes, you can! There is a limit option on the column for that.
$this->crud->addColumns([
[
'name' => 'name',
'label' => 'Name',
'type' => 'text',
'limit' => 150,
],
...
]);

How to reset column value to DEFAULT when updating it with DBIx::Class?

When updating column in postgresql we can reset it value to DEFAULT
UPDATE table SET column = DEFAULT
Is there analogue in DBIx::Class? Just like this:
$schame->result_set( 'table' )->update({ column => DEFAULT })
Thank you to ilmari. I need ref to use literal SQL:
$schame->result_set( 'table' )->update({ column => \'DEFAULT' })

how to do multiple where with same field?

How to convert this script for mongoDB?
select * from table where id > -1 and id in (4,5)
I need to execute this query with two where conditions on the same field.
This doesn't seem to work in PHP:
$db->$col->find(
array(
'id' => array( '$gt' => -1 ),
'id' => array( '$in' => array( 4, 5 ) )
)
);
Basically the problem is that you have a duplicate key in your array so the latter overwrites the prior so your query is only doing the $in.
Most poeople look to $and to solve this problem however, very few know that actually:
'id'=>array('$gt'=>-1, '$in'=>array(4,5))
Will also solve it. You can just chain your constraints for that field.

Proper indexing and sorting with MongoDB

I have a relatively complex query that I'm running. I've included it below, but essentially I have a location query combined with an $or and $in query all to be sorted by date/time. Whenever I run the full query though it returns in ascending order rather than descending.
If I pull out the location part of the query, it successfully returns the results in the proper order, but once I put the location component of the query back in, it continues to fail.
Here's the query as written in php:
$query = array(
'$or' => array(
array( ISPUBLIC => true ),
array( GROUP_INVITES.".".TO.".".INVITE_VAL => array( '$in' => $user_groups ) )
),
LOC => array( '$near' => array( (float)$lon , (float)$lat ), '$maxDistance' => 1 ) //Using 1 degree for the max distance for now
);
$res = $this->db->find( $query )->sort(array('ts'=>-1))->limit($limit)->skip($start);
The fields used are constants that map to fields in the database. My first assumption was that the indexes are not configured properly, but how should I have this indexed when combining geospatial queries with others?
UPDATE
I've been able to replicate the problem by simplifying the query down to:
$query = array(
HOLLER_GROUP_INVITES.".".HOLLER_TO.".".INVITE_VAL => array( '$in' => $user_groups ),
HOLLER_LOC => array( '$near' => array( (float)$lon , (float)$lat ), '$maxDistance' => 1 )
);
UPDATE 2
I've run additional tests and it appears that when limit is removed it's sorted in the correct direction. No idea what's going on here.
This question appears to have the answer: Sorting MongoDB GeoNear results by something other than distance? .... apparently $near was already performing a sort. If you simply want to limit within a given boundary but sort by something else, you should use $within instead of $near.

How to set order of columns where joins are included in select in Zend Framework

Do you know if in case as follows there is any way to set sequence of columns? which is first, which one is second etc?
$select->from(array('e' => 'equipment'), array(
'ID_equipment',
'nr_in',
'equipment_type_ID_equipment_type',
'serial_number',
'barcode',
'sys_create_date',
'sys_deleted',
'status',
'computer_unit_idcomputer_unit',
'room_ID_room',
'action_ID_action',
'invoice_id_invoice',
'quara',
'description'
));
$select->join(array('et' => 'equipment_type'), 'e.equipment_type_ID_equipment_type = et.ID_equipment_type', array('equipment_type_name'));
$select->join(array('i' => 'invoice'), 'i.id_invoice = e.invoice_id_invoice', array('invoice_number'));
These columns which come from joins are placed at the end of all columns and I would like to change placement of this.
Thank you in advance for any help.
Kind Regards,
initially it seems that placing:
'equipment_type_ID_equipment_type as equipment_type_name'
sets column in proper manner (after nr_in)