LISE module saving data to mySQL. Topic is solved

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
andrewvideouk
Forum Members
Forum Members
Posts: 156
Joined: Thu Aug 20, 2020 10:49 pm

LISE module saving data to mySQL.

Post 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);
    }
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3497
Joined: Mon Nov 28, 2011 9:29 am

Re: LISE module saving data to mySQL.

Post 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.
andrewvideouk
Forum Members
Forum Members
Posts: 156
Joined: Thu Aug 20, 2020 10:49 pm

Re: LISE module saving data to mySQL.

Post 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
Post Reply

Return to “Modules/Add-Ons”