Code: Select all
/**
* Gets the display date
* @return date The display date associated with a particular piece of content
*/
function getDisplayDate($content_id)
{
$db =& JFactory::getDBO();
$query = 'SELECT displaydate' .
' FROM #__news_display_date' .
' WHERE content_id = '. $content_id .
' ORDER BY displaydate DESC';
$db->setQuery($query);
$displaydate = $db->loadResult();
// If there is no display date for this particular piece of content
// insert the publish date and return it
if (empty($displaydate)) {
// Get the published date
$query = 'SELECT publish_up FROM #__content WHERE id = ' . $content_id;
$db->setQuery($query);
$publishdate = $db->loadResult();
// Set the display date to the publish date
$this->setDisplayDate($content_id, $publishdate);
return $publishdate;
}
else
return $displaydate;
}
/**
* Sets the display date
* @return bool true if it was entered successfully
*/
function setDisplayDate($content_id, $date)
{
// Include and instantiate the table class
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_news'.DS.'tables');
$row =& JTable::getInstance('NewsDisplayDate', 'Table');
// Put the data into an associative array
$data = array('content_id' => $content_id, 'displaydate' => $date);
// Match the associated items of the array with member variables of the newsdisplaydate table class
if (!$row->bind($data))
return JError::raiseWarning( 500, $row->getError() );
// Store the object in the table
if (!$row->store())
return JError::raiseError(500, $row->getError());
return true;
}
Code: Select all
Before:
TableNewsDisplayDate Object ( [id] => 0 [displaydate] => 1970-01-01 00:00:00 [content_id] => 0 [_tbl] => #__news_display_date [_tbl_key] => content_id [_db] => JDatabaseMySQL Object ( [name] => mysql [_nullDate] => 0000-00-00 00:00:00 [_nameQuote] => ` [_sql] => SELECT publish_up FROM jos_content WHERE id = 948 [_errorNum] => 0 [_errorMsg] => [_table_prefix] => jos_ [_resource] => Resource id #26 [_cursor] => Resource id #163 [_debug] => 0 [_limit] => 0 [_offset] => 0 [_ticker] => 0 [_log] => Array ( ) [_utf] => 1 [_quoted] => Array ( ) [_hasQuoted] => [_errors] => Array ( ) [debug] => 0 ) [_errors] => Array ( ) )
After:
TableNewsDisplayDate Object ( [id] => 0 [displaydate] => 2010-07-19 00:00:00 [content_id] => 948 [_tbl] => #__news_display_date [_tbl_key] => content_id [_db] => JDatabaseMySQL Object ( [name] => mysql [_nullDate] => 0000-00-00 00:00:00 [_nameQuote] => ` [_sql] => SELECT publish_up FROM jos_content WHERE id = 948 [_errorNum] => 0 [_errorMsg] => [_table_prefix] => jos_ [_resource] => Resource id #26 [_cursor] => Resource id #163 [_debug] => 0 [_limit] => 0 [_offset] => 0 [_ticker] => 0 [_log] => Array ( ) [_utf] => 1 [_quoted] => Array ( ) [_hasQuoted] => [_errors] => Array ( ) [debug] => 0 ) [_errors] => Array ( ) )
About an hour ago this thing was actually storing things into the table too. And then it broke and now nothing is saved into the newsdisplaydate table at all. I think I tried deleting the id row in the newsdisplaydate table and changing the pk to content_id and it stopped working after that, but I might be wrong. Of course I dropped the table and recreated it again with exactly the same fields as before the break and it still didn't work, so perhaps it wasn't that after all. I reset apache/mysql too. Hmm. Yes, I'm not sure why it thinks $row->store is working, it's not raising an error. Nothing is going into that table.
Does anybody know why? Thank you.