This is the sql implementation of the Sesha Driver.
Required values for $params:
'phptype' The database type (e.g. 'pgsql', 'mysql', etc.).
'charset' The database's internal charset.
Required by some database implementations:
'hostspec' The hostname of the database server.
'protocol' The communication protocol ('tcp', 'unix', etc.).
'database' The name of the database.
'username' The username with which to connect to the database.
'password' The password associated with 'username'.
'options' Additional options to pass to the database.
'tty' The TTY on which to connect to the database.
'port' The port on which to connect to the database.
Copyright 2003-2012 Horde LLC (http://www.horde.org/)
Copyright 2004-2007 Andrew Coleman mercury@appisolutions.net
See the enclosed file COPYING for license information (GPL). If you
did not receive this file, see http://www.horde.org/licenses/gpl.
Methods summary
public
|
#
__construct( array $params = array() )
This is the basic constructor for the sql driver.
This is the basic constructor for the sql driver.
Parameters
- $params
- Hash containing the connection parameters.
Overrides
|
public
array
|
#
listStock( integer $category_id = null, array $property_ids = array() )
This will retrieve all of the stock items from the database, or just a
particular category of items.
This will retrieve all of the stock items from the database, or just a
particular category of items.
Parameters
- $category_id
- The category ID you want to fetch.
- $property_ids
- The ids of any properties to include in the list.
Returns
array Array of results on success;
|
public
array
|
#
searchStock( string $what, constant $where = SESHA_SEARCH_NAME, array $property_ids = array() )
This will retrieve all matching items from the database.
This will retrieve all matching items from the database.
Parameters
- $what
- What to find.
- $where
- Where to find the information (bitmask).
- $property_ids
- The ids of any properties to include in the list.
Returns
array Array of results on success
|
public
array
|
#
fetch( integer $stock_id )
This function retrieves a single stock item from the database.
This function retrieves a single stock item from the database.
Parameters
- $stock_id
- The numeric ID of the stock item to fetch.
Returns
array a stock item
Throws
|
public
boolean
|
#
delete( integer $stock_id )
Removes a stock entry from the database. Also removes all related
category and property information.
Removes a stock entry from the database. Also removes all related
category and property information.
Parameters
- $stock_id
- The ID of the item to delete.
Returns
boolean True on success
Throws
|
public
integer
|
#
add( array $stock )
This will add a new item to the inventory.
This will add a new item to the inventory.
Parameters
- $stock
- A hash of values for the stock item.
Returns
integer The numeric ID of the newly added item or false.
Throws
|
public
boolean
|
#
modify( array $stock_id, mixed $stock )
This function will modify a pre-existing stock entry with new values.
This function will modify a pre-existing stock entry with new values.
Parameters
- $stock_id
- $stock The hash of values for the inventory item.
- $stock
-
Returns
boolean True on success.
Throws
|
public
array
|
#
getCategory( integer $category_id )
This will return the first category found matching a specific id.
This will return the first category found matching a specific id.
Parameters
- $category_id
- The integer ID of the category to find.
Returns
array The category on success
|
public
array
|
#
getCategories( integer $stock_id = null, integer $category_id = null )
This function return all the categories matching an id.
This function return all the categories matching an id.
Parameters
- $stock_id
- <p>The stock ID of categories to fetch.
Returns all categories if null.</p>
- $category_id
- The numeric ID of the categories to find.
Returns
array The array of matching categories on success, an empty
array otherwise.
|
public
array
|
#
getProperties( integer $property_id = array() )
This will find all the available properties matching a specified ID.
This will find all the available properties matching a specified ID.
Parameters
- $property_id
- <p>The numeric ID of properties to find.
Matches all properties when null.</p>
Returns
array matching properties on success
Throws
|
public
mixed
|
#
getProperty( integer $property_id )
Finds the first matching property for a specified property ID.
Finds the first matching property for a specified property ID.
Parameters
- $property_id
- The numeric ID of properties to find.
Returns
mixed The specified property on success
Throws
|
public
integer
|
#
updateCategory( array $info )
Updates the attributes stored by a category.
Updates the attributes stored by a category.
Parameters
- $info
- Updated category attributes.
Returns
integer The number of affected rows
Throws
|
public
integer
|
#
addCategory( array $info )
Adds a new category for classifying inventory.
Adds a new category for classifying inventory.
Parameters
- $info
- The new category's attributes.
Returns
integer The ID of the new of the category on success
Throws
|
public
integer
|
#
deleteCategory( integer $category_id )
Deletes a category.
Parameters
- $category_id
- The numeric ID of the category to delete.
Returns
integer The number of rows deleted
|
public
boolean
|
#
categoryExists( string $category )
Determines if a category exists in the storage backend.
Determines if a category exists in the storage backend.
Parameters
- $category
- <p>The string representation of the category to
find.</p>
Returns
boolean True on success; false otherwise.
|
public
object
|
#
updateProperty( array $info )
Updates a property with new attributes.
Updates a property with new attributes.
Parameters
- $info
- Array with updated property values.
Returns
object The PEAR DB_Result object from the query.
|
public
object
|
#
addProperty( array $info )
Adds a new property to the storage backend.
Adds a new property to the storage backend.
Parameters
- $info
- Array with new property values.
Returns
object The PEAR DB_Result from the sql query.
|
public
object
|
#
deleteProperty( integer $property_id )
Deletes a property from the storage backend.
Deletes a property from the storage backend.
Parameters
- $property_id
- The numeric ID of the property to delete.
Returns
object The PEAR DB_Result object from the sql query.
|
public
mixed
|
#
getPropertiesForCategories( array $categories = array() )
This will return a set of properties for a set of specified categories.
This will return a set of properties for a set of specified categories.
Parameters
- $categories
- The set of categories to fetch properties.
Returns
mixed An array of properties on success
Throws
|
public
integer
|
#
setPropertiesForCategory( integer $category_id, array $properties = array() )
Updates a category with a set of properties.
Updates a category with a set of properties.
Parameters
- $category_id
- The numeric ID of the category to update.
- $properties
- An array of property ID's to add.
Returns
integer number of inserted row
Throws
|
public
integer
|
#
clearPropertiesForCategory( integer $category_id )
Removes all properties for a specified category.
Removes all properties for a specified category.
Parameters
- $category_id
- The numeric ID of the category to update.
Returns
integer The number of deleted properties
Throws
|
public
object
|
#
getPropertiesForStock( integer $stock_id )
Returns a set of properties for a particular stock ID number.
Returns a set of properties for a particular stock ID number.
Parameters
- $stock_id
- <p>The numeric ID of the stock to find the
properties for.</p>
Returns
object The PEAR DB_Result object from the sql query.
Throws
|
public
object
|
#
clearPropertiesForStock( integer $stock_id, array $categories = array() )
Removes all categories from a particular stock item.
Removes all categories from a particular stock item.
Parameters
- $stock_id
- The numeric ID of the stock item to update.
- $categories
- The array of categories to remove.
Returns
object The PEAR DB_Result object from the sql query.
Throws
|
public
mixed
|
#
updatePropertiesForStock( integer $stock_id, array $properties = array() )
Updates the set of properties for a particular stock item.
Updates the set of properties for a particular stock item.
Parameters
- $stock_id
- The numeric ID of the stock to update.
- $properties
- The hash of properties to update.
Returns
mixed The DB_Result object on success
Throws
|
public
object
|
#
updateCategoriesForStock( integer $stock_id, array $category = array() )
Updates the set of categories for a specified stock item.
Updates the set of categories for a specified stock item.
Parameters
- $stock_id
- The numeric stock ID to update.
- $category
- The array of categories to change.
Returns
object The PEAR DB_Result object from the sql query.
|
public
|
|
public
|
|