Commit graph

107 commits

Author SHA1 Message Date
Joshua Sherman
c9f39e2e18 Updated email address 2014-01-20 15:19:38 -05:00
Joshua Sherman
7c8ae14b75 And then there were none. 2014-01-20 01:25:11 -05:00
Joshua Sherman
54cb6dfe83 Any closer and it would be done
Had to rework the Model class a bit, there's some weirdness happening and I'm
unsure if it's part of the rewrite or always been busted. Won't really know for
sure until I start porting sites over to it I suppose.
2014-01-20 01:06:22 -05:00
Joshua Sherman
db6e169f7b 95% coverage, getting close. 2014-01-19 22:36:30 -05:00
Joshua Sherman
f3d5d12b9f More testing and fixed capitalization fuck up
Seems I went ahead and munged the capitalization for half of the file.
2014-01-19 18:15:13 -05:00
Joshua Sherman
07d2348dd1 More model testing
Getting close!
2014-01-19 14:25:15 -05:00
Joshua Sherman
8655045097 Dropped database JOINs
Not being used and the logic is pretty damn hacky. I don't believe in JOINs so
I'm unsure if this support will be re-added in the future or if there will
simply be a backed in opinion that JOINs are the devil.
2014-01-17 15:46:57 -05:00
Joshua Sherman
68365142e7 Dropped index hinting support
Never gets used, ended up being somewhat MySQL specific as PostgreSQL favors
letting the server handle it instead of hinting at it. Write better queries I
suppose?
2014-01-17 13:14:36 -05:00
Joshua Sherman
57a5b0c2c0 More tests. 2014-01-17 01:53:27 -05:00
Joshua Sherman
51467a60f7 Working on tests for the Model class
Fixed some bugs, got MySQL setup for Travis.
2014-01-16 17:06:31 -05:00
Joshua Sherman
200988eecf Swapped all array() for the shorthand []
Also finished up coverage on the Cache class.
2014-01-15 14:09:54 -05:00
Joshua Sherman
8fc726b983 Updated copyright date.
It's a new year, figured it would be nice to get this done before summer time
like most years.
2014-01-05 13:44:25 -05:00
Joshua Sherman
64dc006b5f Documented some stuff, refactoring some other stuff
Moved re-used object instances to the Object class and added object loader logic to the constructor.
2013-12-30 15:47:13 -05:00
Josh Sherman
9b297f3d87 Dropped Convert::toJSON()
In an effort to only maintain compatibility with the latest version of PHP (currently the 5.5 branch) I dropped the sanity checks if `json_encode` was available as it is always available in PHP 5.2+. Dropping this sanity check also allowed me to remove the wrapper function and the `JSON_AVAILABLE` constant. Ideally I'd like to move towards dropping the `Convert` class entirely but will need a way to convert an array to XML as the `RSS` class still leverages it. One thought is to move that code right into the `RSS` class as it never gets used elsewhere because XML is gross.
2013-12-24 13:28:49 -05:00
Josh Sherman
d96181c60f Q4 2013, seemed like a good time to update the copyright notices 2013-11-04 17:36:04 -05:00
Josh Sherman
058e22c1aa Made method public and fixed return 2013-10-02 15:59:48 -04:00
Josh Sherman
011f9b42b2 Updated to not store empty cache
Primary key queries should not be cached because the record may not exist today but could exist in the future and because the INSERT logic in PICKLES doesn't do any invalidation of the cache.
2013-09-27 13:40:44 -04:00
Josh Sherman
7ed930d278 Fixed issue when passing in single IDs
If you tried to use the extended array syntax to query against the primary key (id) and passed it an integer instead of an array, an error was occurring. Thanks @geoffoliver !
2013-09-22 22:48:07 -04:00
Josh Sherman
dd6ba92e28 Added utility method to extract values from field
Pass it a field name, it'll return an array of all of the values form that field.
2013-09-16 12:59:16 -04:00
Josh Sherman
38e5173823 Updated checks for exactly false.
Fixed some issue withe the sanity checks if the cache results.
2013-09-15 23:32:34 -04:00
Josh Sherman
919ad37717 Added arbitrary cache usage by key.
Pass a Model an optional second or third parameter to force the Model to check the cache before running the query and stashing the results in the key for future queries.
2013-09-15 17:15:22 -04:00
Josh Sherman
dca62b82d1 Removed unnecessary sanity checks when calling Log 2013-09-15 12:02:07 -04:00
Josh Sherman
b6bacdd432 Caching where primary key in ( ... )
Caching was limited to single row selects against the primary key. Expanded to include cache checking and storing when selecting multiple values against the primary key. Does not work on any other row due to the fact that some rows may have duplicate values and the mapping could get borked pretty quick.
2013-09-15 11:56:34 -04:00
Josh Sherman
391e95c9e8 Reverted per column caching aside from id field.
Was a bit messy, just so hard to automagically cache stuff without knowing the data usage.
2013-09-13 13:22:10 -04:00
Josh Sherman
4819b2c1a2 Added sanity check for variable
I like to remove the password field from records when I'm not using the password value, this caused an error when creating the cache keys.
2013-09-11 10:28:38 -04:00
Josh Sherman
9dcf3fa58e Added column caching
If you're pulling data against a single column and returning a single column the UID will be cached out to a key that can easily be recalled the next time the same query is executed. On UPDATE and DELETE the corresponding keys are deleted.
2013-09-10 22:43:52 -04:00
Josh Sherman
d25b042d8e Revert "Reworked Database stuff to be Datastore stuff"
This reverts commit ebd0018473.
2013-02-26 15:14:17 -05:00
Josh Sherman
ebd0018473 Reworked Database stuff to be Datastore stuff
Wanted a generic grouping for all datastores so there's a place for memcached and redis.
2013-02-26 10:15:52 -05:00
Josh Sherman
fe0fd407cf Added inc/decrement functionality to the Model
Sure beats incrementing the variable then setting it! Usage: $model->record['column'] = '++'; // or '--'. Only works with single row updates at the moment. May expand into allowing a variable step to be defined (+10 or ++10 or something... I say that cause I think the double character is a bit safer since you could in theory set a value to -10000 and not want it to decrement by 10k)
2012-12-30 12:21:49 -05:00
Josh Sherman
3290ee0135 Added cache purging post-execution for multiple row UPDATEs 2012-12-02 13:08:36 -05:00
Josh Sherman
50664a22ac Added support for multiple UPDATEs
Also added a new parameter to allow for PDO to handle this correctly as Postgres doesn't allow for multiple row updates in a prepared statement
2012-12-02 12:58:06 -05:00
Josh Sherman
6f80fb51df Added a way to queue records and do a mass INSERT 2012-11-16 17:48:05 -05:00
Josh Sherman
6c7d48278c REPLACE syntax was still using SET even though the way variables were set has changed 2012-11-07 19:53:09 -05:00
Josh Sherman
a0ad85e8e9 Added ability to turn off database auto-cache from the config
Probably should make it a part of the model as well, assuming it doesn't already do that, pretty sure it doesn't. Would help me as one of my sites I need to migrate a ton of code, so being able to flip models on one by one would be excellent.
2012-11-06 11:21:02 -05:00
Josh Sherman
b41f2c12e9 Updated to check if the supposed column names are integers
Simplified logic by only checking one variable. Since "1" is a string but also returns true for being an integer, I swapped the is_string out for an !is_int
2012-11-06 09:13:55 -05:00
Josh Sherman
b2037343d9 Added ability to pass in an array of integers assumed to be ID's
Previously new Model(array(1, 2, 3)); would results in a query like SELECT * FROM table WHERE 1 AND 2 AND 3; which would typically result in an out of memory error depending on the number of rows in the table (as all would be returned). Added detection for an array of integers and forces that to be considered new Model(array('id' => array(1, 2, 3))). As I type this I think I need to go back and make an additional change.
2012-11-06 09:03:03 -05:00
Josh Sherman
99aa78b6fa Built in caching for primary key queries
Selects done against a primary key will automatically cache to Memcached (haven't tried it, but it should fail gracefully) indexed by the model name and the primary key ([NAMESPACE-]MODEL-PKEY). Any updates or deletes against the same primary key will purge the cache automatically. The major caveat here is the case of mass updates which would result in stale data. As it stands the data is being cached for a mere 5 minutes, so this multiple row update scenario would be short lived but ideally, I'll be pushing back the time to live on the cache and/or making it something that's configurable. If you have to do mass updates, you're probably doing them with a cronjob and should just be flushing all of the cache in that scenario (as it would be nearly impossible to detect the affected keys and purge them all).
2012-10-23 23:30:04 -04:00
Josh Sherman
dc0d98906f Added Model and configuration overrides for the column mapping
Also obliterated the getters and setters in the Database class after running some tests against their speed in comparison to getting and setting the variables directly
2012-10-22 10:23:10 -04:00
Josh Sherman
521deddc44 Added injection of is_deleted when doing a query 2012-10-13 11:02:02 -04:00
Josh Sherman
d76e2e71e9 Implemented created, updated, deleted logic.
Automatically inject the creation, update, and delete timestamps as well as which user performed the action. Rows can now be logically deleted and there are no more named parameters just question mark syntax.
2012-10-13 10:18:07 -04:00
Josh Sherman
e05dd7c79e Added check that the table variable is actually set 2012-10-11 21:35:28 -04:00
Josh Sherman
ce61f797f3 Added automatic injection of timestamps 2012-10-11 21:27:22 -04:00
Josh Sherman
a595d85857 Dropped ID variable for Columns
The ID variable was used to map the table's UID so the model could inject it in properly. Added a new variable named columns that is an array of the key columns. Currently contains ID, Created at and Updated at columns. The timestamp columns will soon be injected into the queries and if the value is set to false, will skip it.
2012-10-11 18:56:15 -04:00
Josh Sherman
252ad2fe7b Dropped MongoDB support
There wasn't much to drop as it was never fully integrated. Unfortunately the only things that end up being fully integrated are the things that I actually use. Maybe someday MongoDB, maybe someday.
2012-10-11 17:35:02 -04:00
Josh Sherman
6f114361bd Updated copyright, website and contact email 2012-09-30 12:40:29 -04:00
Josh Sherman
92fcfee986 PostgreSQL support 2012-09-30 12:18:25 -04:00
Josh Sherman
dc916622bb Added *_PRIORITY and IGNORE syntax
Expanded Model class to support queries with priorities as well as the ignore syntax. Priority can be set to LOW or HIGH and will be added to the appropriate queries with the appended _PRIORITY syntax. Ignore is boolean like the Delayed variable.
2011-11-20 13:32:35 -05:00
Josh Sherman
dd4fb702eb Ripped out Mongo code, it's not being used and not being developed against at this time. 2011-11-06 20:53:48 -05:00
Josh Sherman
9fa67d0717 Added logic to snapshot/recall the original object properties. 2011-11-02 22:49:53 -04:00
Josh Sherman
b39a6163e8 Moved logic to run the query out of the constructor. 2011-11-02 22:15:04 -04:00