Class OnpubArticles

Description

Manage articles in an Onpub database.

This class contains the methods to manage the data contained in an OnpubArticles table.

Located in /OnpubArticles.php (line 16)


	
			
Variable Summary
Method Summary
OnpubArticles __construct (PDO $pdo, [bool $enableTransactions = TRUE])
int count ([int $sectionID = NULL])
int delete (int $ID)
OnpubArticle get (int $ID, [OnpubQueryOptions $queryOptions = NULL])
int getID (OnpubArticle $article)
mixed insert (mixed $articles)
array search (string $keywords, [OnpubQueryOptions $queryOptions = NULL])
array select ([OnpubQueryOptions $queryOptions = NULL], [ $sectionID = NULL], [ $websiteID = NULL])
int update (OnpubArticle $article, [bool $overwriteAAMaps = FALSE])
Variables
bool $enableTransactions (line 28)

Controls whether or not the methods in this class use transactions when they access the database.

By default, this is set to TRUE and database transactions will be used where necessary. Set this to FALSE if you want to manage transactions yourself.

  • access: public
Methods
Constructor __construct (line 55)

Connect to an Onpub database.

All the methods in this class which query the database use the database connection provided by the PDO object required by this constructor. Currently, Onpub only supports MySQL as a database for storing content. Therefore, when constructing the PDO object, only the PDO_MYSQL driver is supported as a PDO data source.

All the methods in this class require the Onpub schema to be installed in the PDO-connected database. The OnpubDatabase class contains methods to manage the Onpub schema. The Onpub schema can also be installed by clicking the "Install the schema" link once logged in to the Onpub web interface. The schema generally only has to be installed once per database.

OnpubArticles __construct (PDO $pdo, [bool $enableTransactions = TRUE])
  • PDO $pdo: A PHP Data Object.
  • bool $enableTransactions: If TRUE (the default), the methods in this class that use database transactions will do so. If FALSE, methods that by default use transactions, will not. Only pass FALSE to this argument if you are managing transactions yourself.
count (line 69)

Get the total number of articles in the database.

  • access: public
int count ([int $sectionID = NULL])
  • int $sectionID: Get the total number of articles in a section identified by its ID.
delete (line 99)

Delete an article from the database.

  • return: 1 if the article was deleted, 0 if the article does not exist in the database.
  • access: public
int delete (int $ID)
  • int $ID: ID of the article to delete.
get (line 338)

Get a single article from the database.

  • return: An OnpubArticle object. NULL if the article does not exist in the database.
  • access: public
OnpubArticle get (int $ID, [OnpubQueryOptions $queryOptions = NULL])
  • int $ID: ID of the article to get.
  • OnpubQueryOptions $queryOptions: Optional database query options.
getID (line 514)

Get the ID of an article in the database.

Looks for an article in the database with the same title and content. If there's a match, the ID of the article is returned.

  • return: The ID of the article. NULL if the article does not exist in the database.
  • access: public
int getID (OnpubArticle $article)
insert (line 541)

Insert new article(s) into the database.

  • return: The ID(s) of the new article(s). An int will be returned if a single article was inserted. An array of ints will be returned if multiple articles were inserted.
  • throws: PDOException if there's a database error.
  • access: public
mixed insert (mixed $articles)
  • mixed $articles: A single OnpubArticle object or an array of OnpubArticle objects (to insert multiple articles at a time).
search (line 151)

Search for articles in the database.

  • return: All the articles which were found as an array of OnpubArticle objects.
  • access: public
array search (string $keywords, [OnpubQueryOptions $queryOptions = NULL])
select (line 693)

Get multiple articles from the database.

array select ([OnpubQueryOptions $queryOptions = NULL], [ $sectionID = NULL], [ $websiteID = NULL])
update (line 862)

Update an article already in the database.

If you set the article's sectionIDs to NULL, it will be unmapped from any sections it was previously mapped to.

  • return: 1 if the article was updated. 0 if the article does not exist in the database.
  • access: public
int update (OnpubArticle $article, [bool $overwriteAAMaps = FALSE])
  • OnpubArticle $article: The article to be updated.
  • bool $overwriteAAMaps: False by default. If set to TRUE, the article-author maps for this article will be deleted and recreated, if applicable.

Documentation generated on Fri, 08 Feb 2013 04:02:18 -0500 by phpDocumentor 1.4.4