Kohana v3.3.2

This commit is contained in:
Deon George
2014-09-06 23:43:07 +10:00
parent f96694b18f
commit 8888719653
236 changed files with 1685 additions and 996 deletions

View File

@@ -51,6 +51,10 @@ class Kohana_Auth_ORM extends Auth {
if ( ! $roles->loaded())
return FALSE;
}
else
{
$roles = $role;
}
}
return $user->has('roles', $roles);

View File

@@ -288,8 +288,11 @@ class Kohana_ORM extends Model implements serializable {
*/
protected function _initialize()
{
// Set the object name and plural name
$this->_object_name = strtolower(substr(get_class($this), 6));
// Set the object name if none predefined
if (empty($this->_object_name))
{
$this->_object_name = strtolower(substr(get_class($this), 6));
}
// Check if this model has already been initialized
if ( ! $init = Arr::get(ORM::$_init_cache, $this->_object_name, FALSE))
@@ -1501,14 +1504,14 @@ class Kohana_ORM extends Model implements serializable {
* Returns the number of relationships
*
* // Counts the number of times the login role is attached to $model
* $model->has('roles', ORM::factory('role', array('name' => 'login')));
* $model->count_relations('roles', ORM::factory('role', array('name' => 'login')));
* // Counts the number of times role 5 is attached to $model
* $model->has('roles', 5);
* $model->count_relations('roles', 5);
* // Counts the number of times any of roles 1, 2, 3, or 4 are attached to
* // $model
* $model->has('roles', array(1, 2, 3, 4));
* $model->count_relations('roles', array(1, 2, 3, 4));
* // Counts the number roles attached to $model
* $model->has('roles')
* $model->count_relations('roles')
*
* @param string $alias Alias of the has_many "through" relationship
* @param mixed $far_keys Related model, primary key, or an array of primary keys
@@ -1641,7 +1644,7 @@ class Kohana_ORM extends Model implements serializable {
$this->_build(Database::SELECT);
$records = $this->_db_builder->from(array($this->_table_name, $this->_object_name))
->select(array(DB::expr('COUNT(*)'), 'records_found'))
->select(array(DB::expr('COUNT('.$this->_db->quote_column($this->_object_name.'.'.$this->_primary_key).')'), 'records_found'))
->execute($this->_db)
->get('records_found');
@@ -1651,7 +1654,7 @@ class Kohana_ORM extends Model implements serializable {
$this->reset();
// Return the total number of records in a table
return $records;
return (int) $records;
}
/**

34
modules/orm/composer.json Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "kohana/orm",
"type": "kohana-module",
"description": "The official Kohana ORM module",
"homepage": "http://kohanaframework.org",
"license": "BSD-3-Clause",
"keywords": ["kohana", "framework", "ORM", "database"],
"authors": [
{
"name": "Kohana Team",
"email": "team@kohanaframework.org",
"homepage": "http://kohanaframework.org/team",
"role": "developer"
}
],
"support": {
"issues": "http://dev.kohanaframework.org",
"forum": "http://forum.kohanaframework.org",
"irc": "irc://irc.freenode.net/kohana",
"source": "http://github.com/kohana/core"
},
"require": {
"composer/installers": "~1.0",
"kohana/core": ">=3.3",
"kohana/database": ">=3.3",
"php": ">=5.3.3"
},
"extra": {
"branch-alias": {
"dev-3.3/develop": "3.3.x-dev",
"dev-3.4/develop": "3.4.x-dev"
}
}
}