Is there a way to remove a record from database, but keep the data in entity object? I need to be able to reinsert those detached entities later. Should I work directly on UnitOfWork? Thank you.
I'm not sure of what you are asking, but this looks like the basic behavior of doctrine
$student = new Student();
$student->setName("John doe");
$this->em->persist($student);
$this->em->flush();
$this->printEntity($student);
$this->em->remove($student);
$this->em->flush();
$this->printEntity($student);
This will print out :
Student - id : "1", name : "John doe"
Student - id : "", name : "John doe"
Row is deleted from database but your entity is still populated with others data.
Related
I am using AWS Dynamo DB and am facing an issue.
I have a table which has multiple columns (e.g. firstname, lastname and others). The primary key is an integer.
My requirement is that user can send in one or more search condition and I have fetch data based on this.
e.g. say a Table t1 which has columns Id, firstname, lastname
I am unable to search when user sends in only one search condition.
Below is code:
Table table = dynamoDB.getTable("t1");
Map<String, Object> expressionAttributeValues = new HashMap<String, Object>();
expressionAttributeValues.put(":firstname", "aa");
expressionAttributeValues.put(":lastname", "bb");
ItemCollection<ScanOutcome> items = table.scan
("(firstname = :firstname) AND " +
"(lastname = :lastname)", // FilterExpression
null, // ProjectionExpression
null, // No ExpressionAttributeNames
expressionAttributeValues);
When I send both firstname and lastname as input then the above code works fine.
However if I send in only firstname then the code fails as the lastname input is not being sent.
One crude way to solve this if I make the FilterExpression programatically. I want to know if dynamodb query has inbuilt support for such scenario.
I searched a lot but could not find anything useful.
I have 2 tables, one has a ton of fields so I didn't copy it all but the 2 fields in the big table that I'm working with are "Item Number" and "Item Description". The smaller table is pictured below.
ItemData table
ItemNumber
ItemDescription
Entities
ProductLines
The two tables are not related; I need to have a column in the big table named "Entity" where I lookup the item number or the item description (if the item number is missing) and return what Entity is associated. If both fields are empty then return "NONE".
My current code is below and it works sometimes which doesn't make sense because the code isn't correct, I know. I also can't get it to look at one field if the other is blank which is why that part of the code has been deleted.
Entity = LOOKUPVALUE(ItemData[Entities],ItemData[Item Number],Page1_1[Item Number],"None")
Here is what I want it to say in DAX - Entity = if itemNumber is not null then use item number to retrieve the entity name, otherwise use the itemdescription to find the entity.
Here is what I would like to see:
Item number = "123"
Item Description = "Sunshine"
Entity = "Florida"
I can pull item number and description from the big table. I just need to match those with the small table to get the entity.
You can create an if statement:
Entity = IF(ISEMPTY(ItemData[Item Number]) then
LOOKUPVALUE(ItemData[Entities],ItemData[Item Description],Page1_1[Item Description]) else
LOOKUPVALUE(ItemData[Entities],ItemData[Item Number],Page1_1[Item Number]))
Apologies, I am completely new to Django. My question is that I have 20 records in my database table and suppose 10 record is of same ID and I want to fetch last inserted record for that id I have date column in my table. How can I do that?
last_obj = YourModel.objects.last()
But generally, you can't create > 1 objects with same id, if you didn't specified your own id field to replace built-in. And even then, it's a bad idea.
I have a module ABC in that i need to create another users picklist irrespective of "Assigned To" like already there for every module. I tried to create that by copying existed field for "Assigned To" in vtiger_field table. But it is not working for me nothing new happens in module ABC.
tabid : ABD(tabid)
columname : doneby
tablename : vtiger_crmentity
generatedtype : 1
uitype : 53
fieldname : doneby
fieldlabel : Inspected By
readonly : 1
presence : 2
maximumlength : 100
block : <confused>(Need clarification)
typeofdata : V~M
summaryfield : 1
i really confused with block and typeofdata field.
Can anybody help me to get users list field?
You can easily create it by modifying tablename with vtiger_abc and block is likely to be same as where you expected follow the already existed block which you identify in vtiger_field previous colums in the same table.
More ever you need to create the same name field in vtiger_abc table also which must be varchar(size).
Change the typeofdata with V~0 this is for optional. Because "Assigned To" entity field will have mandatory so if you really need it as mandatory then let it be.
update these two fields.
tablename : vtiger_abc
block : <update with existing block of same table field>
Let's say I have an entity called Game which has a home_school_id. I can of course do $myGame->getHomeSchool()->getId() if I want that school's id, but that takes up too much memory. How can I just directly get home_school_id?
In your GameRepository.php. Then, do a $game->getHomeSchoolId($id);
You'll just have to work with your select, from and where, but that's really easy.
public function getHomeSchoolId($id)
{
return $this
->_em
->createQueryBuilder()
->select('q.home_school_id')
->from('BundleMyBundle:HomeSchool', 'q')
->where('q.something = :id')
->setParameter('id', $id)
->getQuery()
->getResult();
}
If you want the ID of another entity, which is linked through a relation, you'll have to do a join. Just ask if you need more informations.