سؤال

I need to display number of users created from last login to current login in my ELGG application, but there is no field in the ElggUser to record the date & time of users created (ElggUser Table Structure).

So is there any way to get DATETIME of rows already inserted into Table?

Thank You

هل كانت مفيدة؟

المحلول

Database schema of Elgg does contain this information. ElggUser extends ElggEntity that has attributes time_created, time_updated, last_action containing Unix timestamps representation of entity creation/modification/last action by this entity or on related content.

These attributes are stored in {DB_PREFIX}entities table and are availible as properties of all ElggEntity subclasses.

نصائح أخرى

You have to add a field for recording date and time. For instance my table name is my_table and for date time using created_date then create a trigger as:

DELIMITER ;;
    CREATE TRIGGER `my_table_bi` BEFORE INSERT ON `my_table` FOR EACH ROW
BEGIN
    SET NEW.created_date = NOW();
END;;
DELIMITER ;

Every time for added record the trigger will hit recording the date and time of entry

Don't know, if you can alter your table, but you could add a created column like this:

 ALTER TABLE yourTable ADD COLUMN created timestamp DEFAULT CURRENT_TIMESTAMP;

The column created would then always have the time when a row gets inserted without further ado.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top