Example #1
0
	/**
	 * Test for getDbo.
	 *
	 * @covers JTable::getDbo
	 *
	 * @return  void
	 *
	 * @since   12.3
	 */
	public function testGetDbo()
	{
		$this->assertThat(
			$this->object->getDbo(),
			$this->isInstanceOf('JDatabaseDriver')
		);
	}
Example #2
0
 /**
  * Method to add tag rows to mapping table.
  *
  * @param   integer  $ucmId    Id of the #__ucm_content item being tagged
  * @param   JTable   $table    JTable object being tagged
  * @param   array    $tags     Array of tags to be applied.
  *
  * @return  boolean  true on success, otherwise false.
  *
  * @since   3.1
  */
 public function addTagMapping($ucmId, $table, $tags = array())
 {
     $typeId = $this->typeAlias;
     $db = $table->getDbo();
     $key = $table->getKeyName();
     $item = $table->{$key};
     $typeId = $this->getTypeId($this->typeAlias);
     // Insert the new tag maps
     $query = $db->getQuery(true);
     $query->insert('#__contentitem_tag_map');
     $query->columns(array($db->quoteName('type_alias'), $db->quoteName('core_content_id'), $db->quoteName('content_item_id'), $db->quoteName('tag_id'), $db->quoteName('tag_date'), $db->quoteName('type_id')));
     foreach ($tags as $tag) {
         $query->values($db->quote($this->typeAlias) . ', ' . (int) $ucmId . ', ' . (int) $item . ', ' . $db->quote($tag) . ', ' . $query->currentTimestamp() . ', ' . (int) $typeId);
     }
     $db->setQuery($query);
     return (bool) $db->execute();
 }
 /**
  * Get Fields.
  *
  * @param  \JTable  $table
  *
  * @return  array
  */
 public static function getFields(\JTable $table)
 {
     if (empty(static::$fields[$table->getTableName()])) {
         // Lookup the fields for this table only once.
         $name = $table->getTableName();
         $fields = $table->getDbo()->getTableColumns($name, false);
         if (empty($fields)) {
             throw new \UnexpectedValueException(sprintf('No columns found for %s table', $name));
         }
         static::$fields[$table->getTableName()] = $fields;
     }
     return static::$fields[$table->getTableName()];
 }