Hello,
I'm importing topics into groups by a script. What I want to do is creating topics with specific dates. They already have a creation date on original system, so I want to import those with same dates. But when I create topics with variables shown below, it is created with "now" as creation date. How can I set creation date of topics? I also want to do it to comments posted to these topics.
----- HERE, I'm creating topic but donno how to give creation time -----
$grouptopic = new ElggObject();
$grouptopic->subtype = "groupforumtopic";
$grouptopic->owner_guid = $owner_guid;
$grouptopic->container_guid = $group_guid;
$grouptopic->access_id = 2;
$grouptopic->title = "TEST Topic automatically created";
add_entity_relationship ($owner_guid, "member", $group_guid);
$grouptopic->save();
---- AND HERE, I'm adding comments to topic, but donno how to set creation time ----
$grouptopic->status = "open";
$grouptopic->annotate('group_topic_post',"test mesaji","0", $owner_guid);
Thanks a lot
Hakan
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Tek As@htekinaslan
Tek As - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Tek As@htekinaslan
Tek As - 0 likes
- Tek As@htekinaslan
Tek As - 0 likes
- DhrupDeScoop@Dhrup2000
DhrupDeScoop - 0 likes
- Shyam Somanadh@codelust
Shyam Somanadh - 0 likes
You must log in to post replies.Trying to set date of topics to 1 week earlier by
$grouptopic->time_created = time() - (7 * 24 * 60 * 60);
$grouptopic->time_updated = time() - (7 * 24 * 60 * 60);
before save(), but it's still set to "now" in DB.
cannot control that directly ;-(
when you do the $grouptopic->save();
Elgg core will automatically grab *current datetime time() and use that...
You'd have to go back into the table directly to patch the datetime after the ->save
Updated data after save() by the line below, donno if it's the right way;
update_data("UPDATE {$CONFIG->dbprefix}entities set time_created='" . $time_created . "' , time_updated = '" . $time_created . "' where guid='" . $grouptopic->guid . "'");
Thanks :)
yep ;-) snds abt rite..
Won't save() return the GUID on success?
If that is the case you can add an additional step to after the save, do a get_entity and save with the actual date.