Overview

Packages

  • alpha::controller
  • alpha::controller::front
  • alpha::exceptions
  • alpha::model
  • alpha::model::types
  • alpha::tasks
  • alpha::tests
  • alpha::util
  • alpha::util::cache
  • alpha::util::codehighlight
  • alpha::util::convertors
  • alpha::util::feeds
  • alpha::util::filters
  • alpha::util::graphs
  • alpha::util::helpers
  • alpha::util::metrics
  • alpha::view
  • alpha::view::renderers
  • alpha::view::widgets

Classes

  • ActionLogObject
  • AlphaDAO
  • AlphaDAOProviderFactory
  • AlphaDAOProviderMySQL
  • AlphaDAOProviderSQLite
  • ArticleCommentObject
  • ArticleObject
  • ArticleVoteObject
  • BadRequestObject
  • BlacklistedClientObject
  • BlacklistedIPObject
  • PersonObject
  • RightsObject
  • TagObject

Interfaces

  • AlphaDAOProviderInterface
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * An interface that defines all of the Data Access Object (DAO) methods that should be
  5:  * included in a provider that implements this interface.
  6:  *
  7:  * @package alpha::model
  8:  * @since 1.1
  9:  * @author John Collins <dev@alphaframework.org>
 10:  * @version $Id: AlphaDAOProviderInterface.inc 1662 2013-07-09 22:23:29Z alphadevx $
 11:  * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
 12:  * @copyright Copyright (c) 2013, John Collins (founder of Alpha Framework).
 13:  * All rights reserved.
 14:  *
 15:  * <pre>
 16:  * Redistribution and use in source and binary forms, with or
 17:  * without modification, are permitted provided that the
 18:  * following conditions are met:
 19:  *
 20:  * * Redistributions of source code must retain the above
 21:  *   copyright notice, this list of conditions and the
 22:  *   following disclaimer.
 23:  * * Redistributions in binary form must reproduce the above
 24:  *   copyright notice, this list of conditions and the
 25:  *   following disclaimer in the documentation and/or other
 26:  *   materials provided with the distribution.
 27:  * * Neither the name of the Alpha Framework nor the names
 28:  *   of its contributors may be used to endorse or promote
 29:  *   products derived from this software without specific
 30:  *   prior written permission.
 31:  *
 32:  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
 33:  * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
 34:  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 35:  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 36:  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 37:  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 38:  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 39:  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 40:  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 41:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 42:  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 43:  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 44:  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 45:  * </pre>
 46:  *
 47:  */
 48: interface AlphaDAOProviderInterface {
 49:     /**
 50:      * Gets the current connection singleton, or creates a new one if none exists
 51:      *
 52:      * @return mysqli
 53:      * @since 1.1
 54:      */
 55:     public static function getConnection();
 56: 
 57:     /**
 58:      * Disconnects the current database connection if one exists (self::$connection is set)
 59:      *
 60:      * @since 1.1
 61:      */
 62:     public static function disconnect();
 63: 
 64:     /**
 65:      * Returns the last database error string for the current connection.
 66:      *
 67:      * @since 1.1
 68:      * @return string
 69:      */
 70:     public static function getLastDatabaseError();
 71: 
 72:     /**
 73:      * Populates the child object with the properties retrived from the database for the object $OID.
 74:      *
 75:      * @param integer $OID The object ID of the business object to load.
 76:      * @since 1.1
 77:      * @throws BONotFoundException
 78:      */
 79:     public function load($OID);
 80: 
 81:     /**
 82:      * Populates the child object from the database table by the given attribute value.
 83:      *
 84:      * @param string $atribute The name of the attribute to load the object by.
 85:      * @param string $value The value of the attribute to load the object by.
 86:      * @param boolean $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type
 87:      * @param array $loadAttributes The attributes to load from the database to this object (leave blank to load all attributes)
 88:      * @since 1.1
 89:      * @throws BONotFoundException
 90:      */
 91:     public function loadByAttribute($attribute, $value, $ignoreClassType=false, $loadAttributes=array());
 92: 
 93:     /**
 94:      * Loads all of the objects of this class into an array which is returned.
 95:      *
 96:      * @param integer $start The start of the SQL LIMIT clause, useful for pagination.
 97:      * @param integer $limit The amount (limit) of objects to load, useful for pagination.
 98:      * @param string $orderBy The name of the field to sort the objects by.
 99:      * @param string $order The order to sort the objects by.
100:      * @param boolean $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type
101:      * @return array An array containing objects of this type of business object.
102:      * @since 1.1
103:      * @throws BONotFoundException
104:      */
105:     public function loadAll($start=0, $limit=0, $orderBy='OID', $order='ASC', $ignoreClassType=false);
106: 
107:     /**
108:      * Loads all of the objects of this class by the specified attribute into an array which is returned.
109:      *
110:      * @param string $atribute The attribute to load the objects by.
111:      * @param string $value The value of the attribute to load the objects by.
112:      * @param integer $start The start of the SQL LIMIT clause, useful for pagination.
113:      * @param integer $limit The amount (limit) of objects to load, useful for pagination.
114:      * @param string $orderBy The name of the field to sort the objects by.
115:      * @param string $order The order to sort the objects by.
116:      * @param boolean $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type.
117:      * @param array $constructorArgs An optional array of contructor arguements to pass to the BOs that will be generated and returned.  Supports a maximum of 5 arguements.
118:      * @return array An array containing objects of this type of business object.
119:      * @since 1.1
120:      * @throws BONotFoundException
121:      * @throws IllegalArguementException
122:      */
123:     public function loadAllByAttribute($attribute, $value, $start=0, $limit=0, $orderBy="OID", $order="ASC", $ignoreClassType=false, $constructorArgs=array());
124: 
125:     /**
126:      * Loads all of the objects of this class by the specified attributes into an array which is returned.
127:      *
128:      * @param array $atributes The attributes to load the objects by.
129:      * @param array $values The values of the attributes to load the objects by.
130:      * @param integer $start The start of the SQL LIMIT clause, useful for pagination.
131:      * @param integer $limit The amount (limit) of objects to load, useful for pagination.
132:      * @param string $orderBy The name of the field to sort the objects by.
133:      * @param string $order The order to sort the objects by.
134:      * @param boolean $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type
135:      * @return array An array containing objects of this type of business object.
136:      * @since 1.1
137:      * @throws BONotFoundException
138:      * @throws IllegalArguementException
139:      */
140:     public function loadAllByAttributes($attributes=array(), $values=array(), $start=0, $limit=0, $orderBy='OID', $order='ASC', $ignoreClassType=false);
141: 
142:     /**
143:      * Loads all of the objects of this class that where updated (updated_ts value) on the date indicated.
144:      *
145:      * @param string $date The date for which to load the objects updated on, in the format 'YYYY-MM-DD'.
146:      * @param integer $start The start of the SQL LIMIT clause, useful for pagination.
147:      * @param integer $limit The amount (limit) of objects to load, useful for pagination.
148:      * @param string $orderBy The name of the field to sort the objects by.
149:      * @param string $order The order to sort the objects by.
150:      * @param boolean $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type
151:      * @return array An array containing objects of this type of business object.
152:      * @since 1.1
153:      * @throws BONotFoundException
154:      */
155:     public function loadAllByDayUpdated($date, $start=0, $limit=0, $orderBy="OID", $order="ASC", $ignoreClassType=false);
156: 
157:     /**
158:      * Loads all of the specified attribute values of this class by the specified attribute into an
159:      * array which is returned.
160:      *
161:      * @param string $attribute The attribute name to load the field values by.
162:      * @param string $value The value of the attribute to load the field values by.
163:      * @param string $returnAttribute The name of the attribute to return.
164:      * @param string $order The order to sort the BOs by.
165:      * @param boolean $ignoreClassType Default is false, set to true if you want to load from overloaded tables and ignore the class type.
166:      * @return array An array of field values.
167:      * @since 1.1
168:      * @throws BONotFoundException
169:      */
170:     public function loadAllFieldValuesByAttribute($attribute, $value, $returnAttribute, $order='ASC', $ignoreClassType=false);
171: 
172:     /**
173:      * Saves the object.  If $this->OID is empty or null it will INSERT, otherwise UPDATE.
174:      *
175:      * @since 1.1
176:      * @throws FailedSaveException
177:      * @throws LockingException
178:      * @throws ValidationException
179:      */
180:     public function save();
181: 
182:     /**
183:      * Saves the field specified with the value supplied.  Only works for persistent BOs.  Note that no Alpha type
184:      * validation is performed with this method!
185:      *
186:      * @param string $attribute The name of the attribute to save.
187:      * @param mixed $value The value of the attribute to save.
188:      * @since 1.1
189:      * @throws IllegalArguementException
190:      * @throws FailedSaveException
191:      */
192:     public function saveAttribute($attribute, $value);
193: 
194:         /**
195:          * Saves the object history to the [tablename]_history table. It always does an INSERT.
196:          *
197:          * @since 1.2
198:          * @throws FailedSaveException
199:          */
200:     public function saveHistory();
201: 
202:     /**
203:      * Deletes the current object from the database.
204:      *
205:      * @since 1.1
206:      * @throws FailedDeleteException
207:      */
208:     public function delete();
209: 
210:     /**
211:      * Gets the version_num of the object from the database (returns 0 if the BO is not saved yet).
212:      *
213:      * @return integer
214:      * @since 1.1
215:      * @throws BONotFoundException
216:      */
217:     public function getVersion();
218: 
219:     /**
220:      * Builds a new database table for the BO class.
221:      *
222:      * @since 1.1
223:      * @throws AlphaException
224:      */
225:     public function makeTable();
226: 
227:         /**
228:          * Builds a new database table for the BO class to store it's history
229:          *
230:          * @since 1.2
231:          * @throws AlphaException
232:          */
233:         public function makeHistoryTable();
234: 
235:     /**
236:      * Re-builds the table if the model requirements have changed.  All data is lost!
237:      *
238:      * @since 1.1
239:      * @throws AlphaException
240:      */
241:     public function rebuildTable();
242: 
243:     /**
244:      * Drops the table if the model requirements have changed.  All data is lost!
245:      *
246:      * @since 1.1
247:      * @param string $tableName Optional table name, leave blank for the defined table for this class to be dropped
248:      * @throws AlphaException
249:      */
250:     public function dropTable($tableName=null);
251: 
252:     /**
253:      * Adds in a new class property without loosing existing data (does an ALTER TABLE query on the
254:      * database).
255:      *
256:      * @param string $propName The name of the new field to add to the database table.
257:      * @since 1.1
258:      * @throws AlphaException
259:      */
260:     public function addProperty($propName);
261: 
262:     /**
263:      * Gets the maximum OID value from the database for this class type.
264:      *
265:      * @return integer The maximum OID value in the class table.
266:      * @since 1.1
267:      * @throws AlphaException
268:      */
269:     public function getMAX();
270: 
271:     /**
272:      * Gets the count from the database for the amount of objects of this class.
273:      *
274:      * @param array $atributes The attributes to count the objects by (optional).
275:      * @param array $values The values of the attributes to count the objects by (optional).
276:      * @return integer
277:      * @since 1.1
278:      * @throws AlphaException
279:      */
280:     public function getCount($attributes=array(), $values=array());
281: 
282:     /**
283:      * Gets the count from the database for the amount of entries in the [tableName]_history table for this business object.  Only call
284:      * this method on classes where maintainHistory = true, otherwise an exception will be thrown.
285:      *
286:      * @return integer
287:      * @since 1.2
288:      * @throws AlphaException
289:      */
290:     public function getHistoryCount();
291: 
292:     /**
293:      * Populate all of the enum options for this object from the database.
294:      *
295:      * @since 1.1
296:      * @throws AlphaException
297:      */
298:     public function setEnumOptions();
299: 
300:     /**
301:      * Checks to see if the table exists in the database for the current business class.
302:      *
303:      * @param boolean $checkHistoryTable Set to true if you want to check for the existance of the _history table for this DAO.
304:      * @return boolean
305:      * @since 1.1
306:      * @throws AlphaException
307:      */
308:     public function checkTableExists($checkHistoryTable = false);
309: 
310:     /**
311:      * Static method to check the database and see if the table for the indicated BO class name
312:      * exists (assumes table name will be $BOClassName less "Object").
313:      *
314:      * @param string $BOClassName The name of the business object class we are checking.
315:      * @param boolean $checkHistoryTable Set to true if you want to check for the existance of the _history table for this DAO.
316:      * @return boolean
317:      * @since 1.1
318:      * @throws AlphaException
319:      */
320:     public static function checkBOTableExists($BOClassName, $checkHistoryTable = false);
321: 
322:     /**
323:      * Checks to see if the table in the database matches (for fields) the business class definition, i.e. if the
324:      * database table is in sync with the class definition.
325:      *
326:      * @return boolean
327:      * @since 1.1
328:      * @throws AlphaException
329:      */
330:     public function checkTableNeedsUpdate();
331: 
332:     /**
333:      * Returns an array containing any properties on the class which have not been created on the database
334:      * table yet.
335:      *
336:      * @return array An array of missing fields in the database table.
337:      * @since 1.1
338:      * @throws AlphaException
339:      */
340:     public function findMissingFields();
341: 
342:     /**
343:      * Gets an array of all of the names of the active database indexes for this class.
344:      *
345:      * @return array An array of database indexes on this table.
346:      * @since 1.1
347:      * @throws AlphaException
348:      */
349:     public function getIndexes();
350: 
351:     /**
352:      * Creates a foreign key constraint (index) in the database on the given attribute.
353:      *
354:      * @param string $attributeName The name of the attribute to apply the index on.
355:      * @param string $relatedClass The name of the related class in the format "NameObject".
356:      * @param string $relatedClassAttribute The name of the field to relate to on the related class.
357:      * @param bool $allowNullValues For foreign key indexes that don't allow null values, set this to false (default is true).
358:      * @since 1.1
359:      * @throws FailedIndexCreateException
360:      */
361:     public function createForeignIndex($attributeName, $relatedClass, $relatedClassAttribute);
362: 
363:     /**
364:      * Creates a unique index in the database on the given attribute(s).
365:      *
366:      * @param string $attribute1Name The first attribute to mark unique in the database.
367:      * @param string $attribute2Name The second attribute to mark unique in the databse (optional, use only for composite keys).
368:      * @param string $attribute3Name The third attribute to mark unique in the databse (optional, use only for composite keys).
369:      * @since 1.1
370:      * @throws FailedIndexCreateException
371:      */
372:     public function createUniqueIndex($attribute1Name, $attribute2Name = '', $attribute3Name = '');
373: 
374:     /**
375:      * Reloads the object from the database, overwritting any attribute values in memory.
376:      *
377:      * @since 1.1
378:      * @throws AlphaException
379:      */
380:     public function reload();
381: 
382:     /**
383:      * Checks that a record exists for the BO in the database.
384:      *
385:      * @param int $OID The Object ID of the object we want to see whether it exists or not.
386:      * @return boolean
387:      * @since 1.1
388:      * @throws AlphaException
389:      */
390:     public function checkRecordExists($OID);
391: 
392:     /**
393:      * Checks to see if the table name matches the classname, and if not if the table
394:      * name matches the classname name of another BO, i.e. the table is used to store
395:      * multiple types of BOs.
396:      *
397:      * @return bool
398:      * @since 1.1
399:      * @throws BadBOTableNameException
400:      */
401:     public function isTableOverloaded();
402: 
403:     /**
404:      * Starts a new database transaction.
405:      *
406:      * @since 1.1
407:      * @throws AlphaException
408:      */
409:     public static function begin();
410: 
411:     /**
412:      * Commits the current database transaction.
413:      *
414:      * @since 1.1
415:      * @throws FailedSaveException
416:      */
417:     public static function commit();
418: 
419:     /**
420:      * Aborts the current database transaction.
421:      *
422:      * @since 1.1
423:      * @throws AlphaException
424:      */
425:     public static function rollback();
426: 
427:     /**
428:      * Provide the BO that we are going to map the data to from this provider.
429:      *
430:      * @param AlphaDAO $BO
431:      * @since 1.1
432:      */
433:     public function setBO($BO);
434: 
435:     /**
436:      * Returns a 2d array, where each element in the array is another array
437:      * representing a database row.
438:      *
439:      * @param string $sqlQuery
440:      * @throws CustomQueryException
441:      * @return array
442:      * @since 1.1
443:      */
444:     public function query($sqlQuery);
445: }
446: 
447: ?>
Alpha Framework ${alpha.version.new} API Documentation API documentation generated by ApiGen 2.8.0