Skip to content

PHP ActiveRecord library supporting complex queries, hydration, and persistence features.

Notifications You must be signed in to change notification settings

rollthecloudinc/druid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic library Usage
----------------------------------

1.) Go to config file and fill in database connection info
2.) Set write permissions on root library directory
3.) Include or run main.php

NOTE: The first time main.php is ran it will crawl through
the defined database in the config file and generate all base
model file templates. This is a good place to start, but once
your application starts requiring advanced associations you will
need to go through each model file and define those associations that
could not be automatically resolved.

The model files will be placed inside the model directory upon
sucess of the rake script. From which point you can begin leveraging
the true power of the entire library. No need to include model files
or define a connection as this is all handled internally by the library.

If you need to access the connection object once instantiated you
may do so by calling ActiveRecord::getConnection() which returns
the PDO instance used to connect to the defined database in the config.

Additional
-----------------------------------

Table names should be plural:

IE. blogs NOT blog

Model classes will be singular:

User::find() NOT Users::find()

----------------------------------

If you have ran the main script and would like to start
over just dump the model directory. The presence of the model
directory is what dictates the rake script being ran. So once
you remove the model directory the next time the main script
is ran it will regenerate the model files using the current
config definition.

----------------------------------
* More documentation to come


Query Transformations

Selects support both pre and post query transformations. A pre
query transformation can be used in the form of a string
with special placehoders. Practical uses for this is to easily
convert 1 or 0 to true and false. Additionally at the save
stage a transform can be applied to properly convery true/false
value to 1/0 for the database.

Also, both select and save support transformation callbacks in the form
of either a static/public method on the active record or function. This
can be useful for serialized data. In the case of a serialzed column a select
callback transformation can be used to unserialize the data. Yet, a save callback
transformation can be used to serialize the data before saving it to the presistent
storage facility.




About

PHP ActiveRecord library supporting complex queries, hydration, and persistence features.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages