# Class Crud

The CRUD class is a base class which acts as an interface between any objects which are stored on in the database and represented in server side logic, for example Map, Marker, Polygon

  WPGMZA\Factory
  WPGMZA\Crud implements IteratorAggregate, JsonSerializable

#### Direct known subclasses

WPGMZA\Map, WPGMZA\Marker

#### Indirect known subclasses

WPGMZA\GoogleMap, WPGMZA\ProMap, WPGMZA\ProMarker
Namespace: WPGMZA
Located at class.crud.php

Methods summary
`public` | # `__construct( string $table_name, integer|array|object $id_or_fields = -1, $read_mode = Crud::SINGLE_READ )` Constructor Constructor #### Parameters $table_name The table name for this object type $id_or_fields The ID of the object to read, or an object or array of data to insert. $read_mode
`public static` | # `bulk_read( $data, $constructor )`
`public static` | # `bulk_trash( $ids )`
`public string` | # `get_table_name( )` Gets the table name for this object type Gets the table name for this object type #### Returns string
`public array` | # `get_columns( )` Gets the column information (name, type, etc.) Gets the column information (name, type, etc.) #### Returns array
`public array` | # `get_column_names( )` Returns an array of the column names represented as strings Returns an array of the column names represented as strings #### Returns array
`public string` | # `get_column_type( $name )` Return the SQL field type of the specified column Return the SQL field type of the specified column #### Returns string
`protected string` | # `get_placeholder_by_type( string $type )` Gets the placeholder for a prepared statement based on the SQL column type specified. Gets the placeholder for a prepared statement based on the SQL column type specified. #### Parameters $type The SQL data type #### Returns string A placeholder, such as %s, %d or %f
`protected mixed` | # `get_column_parameter( string $name )` Gets the parameter to be passed to a prepared statement, from this object, by the name of the DB column given. Gets the parameter to be passed to a prepared statement, from this object, by the name of the DB column given. #### Parameters $name The database column name #### Returns mixed The value of the specified field name from this object
`protected array` | # `get_column_placeholders( )` Gets all the placeholders for a prepared statement Gets all the placeholders for a prepared statement #### Returns array An array of string placeholders
`protected array` | # `get_column_parameters( )` Gets all the values to be passed to a prepared statement from this object Gets all the values to be passed to a prepared statement from this object #### Returns array An array of the values from this object
`protected string` | # `get_arbitrary_data_column_name( )` Gets the column name used to store arbitrary data, for instance, other_data, or NULL for tables which do not have such a field. Gets the column name used to store arbitrary data, for instance, other_data, or NULL for tables which do not have such a field. #### Returns string The name of the column used to store arbitrary data
`protected` | # `assert_not_trashed( )` Asserts that this object hasn't been trashed and throws an exception if it has Asserts that this object hasn't been trashed and throws an exception if it has #### Throws Exception
`protected boolean` | # `column_exists( $name )` Returns true if the named column exists on this map objects table Returns true if the named column exists on this map objects table #### Returns boolean
`protected` | # `parse_arbitrary_data( $data )` Parses arbitrary data following a DB read, for example by unserializing strings or decoding JSON. Parses arbitrary data following a DB read, for example by unserializing strings or decoding JSON.
`protected` | # `store_arbitrary_data( $key, $value )` Stores arbitrary data. This is not currently used. Stores arbitrary data. This is not currently used.
`protected` | # `create( )` Creates the map object in the database Creates the map object in the database #### Throws Exception The object has been trashed
`protected` | # `read( $mode )` Reads the data from the database into this object Reads the data from the database into this object #### Throws Exception The object has been trashed
`protected boolean` | # `is_read_only( $key )` Returns true if the specified property is read only Returns true if the specified property is read only #### Returns boolean Whether or not the property is read only
`public` | # `update( )` Updates the map object in the database Updates the map object in the database #### Returns $this #### Throws Exception The object has been trashed
`public` | # `trash( )` Deletes the object from the database and sets the trashed flag Deletes the object from the database and sets the trashed flag #### Throws Exception The object has been trashed
`public` | # `set( string|array|object $arg, $val = null )` Set variables in bulk, this reduces the number of database calls Set variables in bulk, this reduces the number of database calls #### Parameters $arg a string naming the property to be set (with a second argument which is the value), or an array or object of key and value pairs to be set on this object $val #### Returns $this #### Throws Exception The object has been trashed
`public ArrayIterator` | # `getIterator( )` Get's the iterator for iterating over map object properties Get's the iterator for iterating over map object properties #### Returns ArrayIterator #### Throws Exception The object has been trashed #### Implementation of `IteratorAggregate::getIterator()`
`public array` | # `jsonSerialize( )` Returns the objects properties to be serialized as JSON Returns the objects properties to be serialized as JSON #### Returns array #### Throws Exception #### Implementation of `JsonSerializable::jsonSerialize()`
`public mixed` | # `__get( $name )` Magic method to get map object fields Magic method to get map object fields #### Returns mixed #### Throws Exception The object has been trashed #### Params string $name The name of the property to read
`public boolean` | # `__isset( $name )` Checks if a field is set by name Checks if a field is set by name #### Returns boolean #### Throws Exception The object has been trashed. #### Params string $name The name of the property to check
`public` | # `__set( string $name, mixed $value )` Sets the property value by name and updates the database Sets the property value by name and updates the database #### Parameters $name The property name $value The value to set on the specified property #### Throws Exception The object has been trashed Exception The specified property is read-only
`public` | # `__unset( $name )` Unsets the named variable, only valid for arbitrary data Unsets the named variable, only valid for arbitrary data #### Throws Exception when attempting to unset a column, as opposed to arbitrary data.

Methods inherited from WPGMZA\Factory
`createInstance()`

Constants summary
`string` | `SINGLE_READ` | # `"single-read"`
`string` | `BULK_READ` | # `"bulk-read"`