Skip to content

[WIP] 1.1 Updates #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 60 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
cf93036
Allow custom setter methods to run for aliased attributes (fixes #350)
leightonshank Jul 8, 2013
7e58a68
Remove require_once from inside functions
andyleap May 29, 2013
dc13eee
remove all carriage returns <CR>
koenpunt Jul 17, 2014
65d5c48
normalize file endings
koenpunt Jul 17, 2014
7de8cd3
Added option for multiple model directories
koenpunt Jun 27, 2012
9f150f9
Added tests
koenpunt Apr 20, 2013
c8bb4b9
Adding custom support for boolean casting based on connection
leightonshank Nov 8, 2012
1bd40ea
Updated ColumnTest for new BOOLEAN type cast
leightonshank Nov 8, 2012
9800a13
fixed indentation formatting to match existing code
leightonshank Apr 30, 2013
b960575
Updated tests for boolean value casting
leightonshank Apr 30, 2013
71fe0d4
Updated PgsqlAdapter boolean_to_string() for Postgres boolean values
leightonshank Apr 30, 2013
09e6207
Shortened the false condition in PgsqlAdapter::boolean_to_string()
leightonshank May 1, 2013
f892c2c
Added some newlines for readability.
Jul 21, 2012
5cbb536
Implemented 'on' option for validations.
Jul 21, 2012
b2e2337
Added tests for on create/update/save
koenpunt Sep 25, 2012
c815875
Only flag attributes as dirty if the value changes
leightonshank Jul 10, 2013
4f209d9
Added tracking of changed attributes
leightonshank Jul 10, 2013
6770e71
Fix handling of changed DateTime attributes
leightonshank Jul 11, 2013
53b9951
Fix so that empty attributes still track a change
leightonshank Jul 19, 2013
b958b05
Fix PgsqlAdapter native types, default values.
Jun 13, 2013
198fc20
fix indentation
koenpunt Jul 20, 2014
044b0e1
require Expressions by default
koenpunt Jul 19, 2014
52f422a
Make sure that the primary key is stored in lowercase
kamrandotpk Apr 18, 2013
427a419
Allows for aliased methods in serialization, so we can do stuff like …
igorsantos07 Jun 20, 2013
1d4f312
add test for serialization method alias
koenpunt Jul 20, 2014
8bfb68b
cast count result as integer
daniel-aranda Jan 23, 2015
8b0b67e
FIX jpfuentes2#361
nicknill Jan 13, 2014
9e8c27b
make string buildup more readable
koenpunt Dec 8, 2014
14e926a
Refactor is_hash()
Dec 13, 2014
1523023
Merge pull request #483 from getloaded/custom-setter-for-aliased-attr…
koenpunt Jan 19, 2015
352e1b6
Merge pull request #492 from daniel-aranda/model_cast_count_as_integer
koenpunt Feb 16, 2015
c03d7b5
Merge branch 'master' into 1.1-dev
koenpunt Jun 3, 2017
bdbaebb
Feature: StrongParameters
koenpunt Dec 12, 2014
16e6f4b
Require StrongParameters
koenpunt Jan 19, 2015
14ef260
add requireParam and fetch function
koenpunt Jun 3, 2017
f941f45
add some docblocks
koenpunt Jun 3, 2017
ab0432c
is_valid don't always revalidate the model. Added test also.
iazel Apr 25, 2013
f7241b5
fix whitespace and coding style
koenpunt Dec 6, 2014
e3d6a56
separate connection string parsing from connection
koenpunt Feb 9, 2015
b7c617e
use parse_str for query string parsing
koenpunt Feb 9, 2015
7d611e1
use factual decode param checking
koenpunt Feb 9, 2015
a90e8cd
use sscanf instead of regex
koenpunt Feb 9, 2015
5a6f015
assert database name for unix socket
koenpunt Feb 9, 2015
35bf5f1
check if property exists before assignment
koenpunt Feb 10, 2015
3781525
build ConnectionInfo objects on instantiation
koenpunt Feb 10, 2015
7c8eaa8
add array example
koenpunt Feb 10, 2015
4507f7f
rename protocol to adapter
koenpunt Feb 10, 2015
d447040
add docblocks
koenpunt Jun 4, 2017
290089b
use is_hash instead of is_array
koenpunt Jun 11, 2017
59d8427
add snake_case alias for requireParam
koenpunt Jun 11, 2017
939dc78
implement ArrayAccess
koenpunt Jun 11, 2017
74ac838
resolve test issues
koenpunt Dec 6, 2014
5af90ef
update naming of validated flag
koenpunt Dec 6, 2014
2f23190
simplify docblock for is_valid
koenpunt Jun 3, 2017
c3bf5ba
Merge pull request #480 from koenpunt/strong-parameters
koenpunt Jun 11, 2017
39343c1
Merge pull request #464 from jpfuentes2/Iazel-hmt-and-is_valid-fixes
koenpunt Jun 11, 2017
54f8d4f
failing test for #68
koenpunt Jul 19, 2014
9c43bdb
Fix for issue 68: relationship references wrong table
Apr 13, 2011
05b3277
Merge pull request #436 from jpfuentes2/jmoberley-issue_68
koenpunt Jun 12, 2017
d5f1895
Merge pull request #494 from koenpunt/array-connection-info
koenpunt Jun 12, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 60 additions & 50 deletions ActiveRecord.php
Original file line number Diff line number Diff line change
@@ -1,50 +1,60 @@
<?php
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300)
die('PHP ActiveRecord requires PHP 5.3 or higher');

define('PHP_ACTIVERECORD_VERSION_ID','1.0');

if (!defined('PHP_ACTIVERECORD_AUTOLOAD_PREPEND'))
define('PHP_ACTIVERECORD_AUTOLOAD_PREPEND',true);

require __DIR__.'/lib/Singleton.php';
require __DIR__.'/lib/Config.php';
require __DIR__.'/lib/Utils.php';
require __DIR__.'/lib/DateTimeInterface.php';
require __DIR__.'/lib/DateTime.php';
require __DIR__.'/lib/Model.php';
require __DIR__.'/lib/Table.php';
require __DIR__.'/lib/ConnectionManager.php';
require __DIR__.'/lib/Connection.php';
require __DIR__.'/lib/Serialization.php';
require __DIR__.'/lib/SQLBuilder.php';
require __DIR__.'/lib/Reflections.php';
require __DIR__.'/lib/Inflector.php';
require __DIR__.'/lib/CallBack.php';
require __DIR__.'/lib/Exceptions.php';
require __DIR__.'/lib/Cache.php';

if (!defined('PHP_ACTIVERECORD_AUTOLOAD_DISABLE'))
spl_autoload_register('activerecord_autoload',false,PHP_ACTIVERECORD_AUTOLOAD_PREPEND);

function activerecord_autoload($class_name)
{
$path = ActiveRecord\Config::instance()->get_model_directory();
$root = realpath(isset($path) ? $path : '.');

if (($namespaces = ActiveRecord\get_namespaces($class_name)))
{
$class_name = array_pop($namespaces);
$directories = array();

foreach ($namespaces as $directory)
$directories[] = $directory;

$root .= DIRECTORY_SEPARATOR . implode($directories, DIRECTORY_SEPARATOR);
}

$file = "$root/$class_name.php";

if (file_exists($file))
require_once $file;
}
<?php
if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300)
die('PHP ActiveRecord requires PHP 5.3 or higher');

define('PHP_ACTIVERECORD_VERSION_ID','1.0');

if (!defined('PHP_ACTIVERECORD_AUTOLOAD_PREPEND'))
define('PHP_ACTIVERECORD_AUTOLOAD_PREPEND',true);

require __DIR__.'/lib/Singleton.php';
require __DIR__.'/lib/Config.php';
require __DIR__.'/lib/Utils.php';
require __DIR__.'/lib/DateTimeInterface.php';
require __DIR__.'/lib/DateTime.php';
require __DIR__.'/lib/Model.php';
require __DIR__.'/lib/Table.php';
require __DIR__.'/lib/ConnectionManager.php';
require __DIR__.'/lib/Connection.php';
require __DIR__.'/lib/ConnectionInfo.php';
require __DIR__.'/lib/Serialization.php';
require __DIR__.'/lib/Expressions.php';
require __DIR__.'/lib/SQLBuilder.php';
require __DIR__.'/lib/Reflections.php';
require __DIR__.'/lib/Inflector.php';
require __DIR__.'/lib/CallBack.php';
require __DIR__.'/lib/Exceptions.php';
require __DIR__.'/lib/Cache.php';
require __DIR__.'/lib/StrongParameters.php';

if (!defined('PHP_ACTIVERECORD_AUTOLOAD_DISABLE'))
spl_autoload_register('activerecord_autoload',false,PHP_ACTIVERECORD_AUTOLOAD_PREPEND);

function activerecord_autoload($class_name)
{
$paths = ActiveRecord\Config::instance()->get_model_directories();
$namespace_directory = '';
if (($namespaces = ActiveRecord\get_namespaces($class_name)))
{
$class_name = array_pop($namespaces);
$directories = array();

foreach ($namespaces as $directory)
$directories[] = $directory;

$namespace_directory = DIRECTORY_SEPARATOR . implode($directories, DIRECTORY_SEPARATOR);
}
$paths = count($paths) ? $paths : array('.');

foreach($paths as $path)
{
$root = realpath($path);
$file = "{$root}{$namespace_directory}/{$class_name}.php";

if (file_exists($file))
{
require $file;
return;
}
}
}
19 changes: 11 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,17 @@ Example:
```php
ActiveRecord\Config::initialize(function($cfg)
{
$cfg->set_model_directory('/path/to/your/model_directory');
$cfg->set_connections(
array(
'development' => 'mysql://username:password@localhost/development_database_name',
'test' => 'mysql://username:password@localhost/test_database_name',
'production' => 'mysql://username:password@localhost/production_database_name'
)
);
$cfg->set_model_directories(array(
'/path/to/your/model_directory',
'/some/other/path/to/your/model_directory'
));
$cfg->set_connections(
array(
'development' => 'mysql://username:password@localhost/development_database_name',
'test' => 'mysql://username:password@localhost/test_database_name',
'production' => 'mysql://username:password@localhost/production_database_name'
)
);
});
```

Expand Down
1 change: 0 additions & 1 deletion examples/orders/models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,3 @@ public function apply_tax()
$this->tax = $this->price * $tax;
}
}
?>
1 change: 0 additions & 1 deletion examples/orders/models/Payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ class Payment extends ActiveRecord\Model
array('person'),
array('order'));
}
?>
1 change: 0 additions & 1 deletion examples/orders/models/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ class Person extends ActiveRecord\Model
static $validates_presence_of = array(
array('name'), array('state'));
}
?>
2 changes: 1 addition & 1 deletion examples/orders/orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@

foreach ($order->people as $person)
echo " payment of $$person->amount by " . $person->name . "\n";
?>

1 change: 0 additions & 1 deletion examples/simple/simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,3 @@ class Book extends ActiveRecord\Model { }
});

print_r(Book::first()->attributes());
?>
1 change: 0 additions & 1 deletion examples/simple/simple_with_options.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,3 @@ class Book extends ActiveRecord\Model
});

print_r(Book::first()->attributes());
?>
Loading