Page 1 of 1

LISE module saving data to mySQL.

Posted: Mon Dec 13, 2021 10:47 pm
by andrewvideouk
I have a small problem. I am try to write to mysql using $LISEinstance. I have everything working great. The only problem I can’t to save the create_time or modified_time. At the moment I got a custom date field and saving it there. I really want to use the create_time and modified_time. It's only saving the current time not the time I want. Is something missing? I am sure I am using the right datetime format.

Can someone help.

Cheers


Code: Select all


$LISEinstance = \cms_utils::get_module('LISEYouTube');    
    $edit = $LISEinstance->LoadItemByIdentifier('alias', $SaveVideo_id); 
        // creates an (almost) empty object if item doesn't exist 
    $url_prefix = $LISEinstance->GetPreference('url_prefix');
    $detail_page = $LISEinstance->GetPreference('page_alias');
    $url_Setpath = 'video/'.$SaveVideo_id;
    if (!isset($edit->item_id))
    {
        // doesn't exist yet so create new LISE item
        $vitem = $LISEinstance->InitiateItem();
        $vitem->medium_image = $vdata->items[0]->snippet->thumbnails->medium->url;
        $vitem->maxres_image = $vdata->items[0]->snippet->thumbnails->maxres->url;
        $vitem->views = number_format_short($vdata->items[0]->statistics->viewCount);
        $vitem->duration = YouTube_TimeCode($vdata->items[0]->contentDetails->duration);
        $vitem->duration_text = Time_Words($vdata->items[0]->snippet->publishedA);
        $vitem->video_id = htmlspecialchars($SaveVideo_id);
        $vitem->url = $url_Setpath;
        $vitem->date_published = '2020-07-13 21:55:54; // WORKING with custom date field
        $vitem->create_time = '2020-07-13 21:55:54'; // NOT WORKING
        // added these
        $vitem->title = $vdata->items[0]->snippet->title;
        $vitem->description = htmlspecialchars($vdata->items[0]->snippet->description); 
        $vitem->alias = htmlspecialchars($SaveVideo_id);
        $vitem->playlist = $category_id;
        $LISEinstance->SaveItem($vitem);
    }
    else 
    {    
        // does exist so just edit existing  LISE item  
        $vitem = $LISEinstance->LoadItemByIdentifier('alias', $SaveVideo_id);         
        $vitem->alias = htmlspecialchars($SaveVideo_id);    // alreay exists - don't update         
        // the following get updated        
        $vitem->views = number_format_short($vdata->items[0]->statistics->viewCount);      
        $vitem->create_time = '2020-07-13 21:55:54'; // NOT WORKING
        $LISEinstance->SaveItem($vitem);
    }

Re: LISE module saving data to mySQL.

Posted: Tue Dec 14, 2021 3:16 pm
by velden
Without looking at the code I suppose those properties aren't meant to be written by you.
If you need to do something with dates I'd suggest to add some custom fields for that.

Re: LISE module saving data to mySQL.

Posted: Sun Dec 19, 2021 3:29 pm
by andrewvideouk
Thank you. Only problem i did not know had how to orderby with a custom date field. I did not know I had to add custom_ before field name orderby='custom_date_published|ASC’.

I do hope one day we can use the create_time and modified_time.


Thank you