parent
2c16937dec
commit
e3f5aa9fb2
@ -235,6 +235,17 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
|||||||
|
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* convertBoolean
|
||||||
|
* converts boolean to integers
|
||||||
|
*
|
||||||
|
* @param mixed $item
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function convertBoolean(&$item) {
|
||||||
|
if(is_bool($item))
|
||||||
|
$item = (int) $item;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* execute
|
* execute
|
||||||
* executes the dql query and populates all collections
|
* executes the dql query and populates all collections
|
||||||
@ -246,6 +257,8 @@ abstract class Doctrine_Hydrate extends Doctrine_Access {
|
|||||||
$this->data = array();
|
$this->data = array();
|
||||||
$this->collections = array();
|
$this->collections = array();
|
||||||
|
|
||||||
|
array_walk($params, array(__CLASS__, 'convertBoolean'));
|
||||||
|
|
||||||
if( ! $this->view)
|
if( ! $this->view)
|
||||||
$query = $this->getQuery();
|
$query = $this->getQuery();
|
||||||
else
|
else
|
||||||
|
@ -75,13 +75,18 @@ class Doctrine_Query_Where extends Doctrine_Query_Condition {
|
|||||||
$enumIndex = $table->enumIndex($field, trim($value,"'"));
|
$enumIndex = $table->enumIndex($field, trim($value,"'"));
|
||||||
$alias = $this->query->getTableAlias($reference);
|
$alias = $this->query->getTableAlias($reference);
|
||||||
$table = $this->query->getTable($alias);
|
$table = $this->query->getTable($alias);
|
||||||
|
|
||||||
|
if(trim($value) == 'true')
|
||||||
|
$value = 1;
|
||||||
|
elseif(trim($value) == 'false')
|
||||||
|
$value = 0;
|
||||||
|
|
||||||
switch($operator) {
|
switch($operator) {
|
||||||
case '<':
|
case '<':
|
||||||
case '>':
|
case '>':
|
||||||
case '=':
|
case '=':
|
||||||
if($enumIndex !== false)
|
if($enumIndex !== false)
|
||||||
$value = $enumIndex;
|
$value = $enumIndex;
|
||||||
|
|
||||||
$where = $alias.'.'.$field.' '.$operator.' '.$value;
|
$where = $alias.'.'.$field.' '.$operator.' '.$value;
|
||||||
break;
|
break;
|
||||||
|
@ -324,6 +324,10 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
|||||||
case "enum":
|
case "enum":
|
||||||
$this->data[$name] = $this->table->enumValue($name, $tmp[$name]);
|
$this->data[$name] = $this->table->enumValue($name, $tmp[$name]);
|
||||||
break;
|
break;
|
||||||
|
case "boolean":
|
||||||
|
case "integer":
|
||||||
|
if($tmp[$name] !== self::$null)
|
||||||
|
settype($tmp[$name], $type);
|
||||||
default:
|
default:
|
||||||
$this->data[$name] = $tmp[$name];
|
$this->data[$name] = $tmp[$name];
|
||||||
endswitch;
|
endswitch;
|
||||||
@ -889,6 +893,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
|
|||||||
case 'gzip':
|
case 'gzip':
|
||||||
$a[$v] = gzcompress($this->data[$v],5);
|
$a[$v] = gzcompress($this->data[$v],5);
|
||||||
break;
|
break;
|
||||||
|
case 'boolean':
|
||||||
|
$a[$v] = (int) $this->data[$v];
|
||||||
|
break;
|
||||||
case 'enum':
|
case 'enum':
|
||||||
$a[$v] = $this->table->enumIndex($v,$this->data[$v]);
|
$a[$v] = $this->table->enumIndex($v,$this->data[$v]);
|
||||||
break;
|
break;
|
||||||
|
@ -13,8 +13,7 @@ Following data types are availible in doctrine:
|
|||||||
<li /><b> object </b>
|
<li /><b> object </b>
|
||||||
<ul> The same as type 'object' in php. Automatically serialized when saved into database and unserialized when retrieved from database.</ul>
|
<ul> The same as type 'object' in php. Automatically serialized when saved into database and unserialized when retrieved from database.</ul>
|
||||||
<li /><b> enum </b>
|
<li /><b> enum </b>
|
||||||
<ul> Unified 'enum' type. Automatically converts the string values into index numbers and vice versa. The possible values for the column
|
<ul> </ul>
|
||||||
can be specified with Doctrine_Record::setEnumValues(columnName, array values).</ul>
|
|
||||||
<li /><b> timestamp </b>
|
<li /><b> timestamp </b>
|
||||||
<dd /> Database 'timestamp' type
|
<dd /> Database 'timestamp' type
|
||||||
<li /><b> clob</b>
|
<li /><b> clob</b>
|
||||||
|
@ -102,6 +102,16 @@ $menu = array("Getting started" =>
|
|||||||
"Enum emulation",
|
"Enum emulation",
|
||||||
|
|
||||||
),
|
),
|
||||||
|
|
||||||
|
"Record identifiers" => array(
|
||||||
|
"Introduction",
|
||||||
|
"Autoincremented",
|
||||||
|
"Natural",
|
||||||
|
"Composite",
|
||||||
|
"Sequential")
|
||||||
|
),
|
||||||
|
"Schema reference" =>
|
||||||
|
array(
|
||||||
"Data types" => array(
|
"Data types" => array(
|
||||||
"Boolean",
|
"Boolean",
|
||||||
"Integer",
|
"Integer",
|
||||||
@ -116,26 +126,7 @@ $menu = array("Getting started" =>
|
|||||||
"Enum",
|
"Enum",
|
||||||
"Gzip",
|
"Gzip",
|
||||||
),
|
),
|
||||||
"Record identifiers" => array(
|
|
||||||
"Introduction",
|
|
||||||
"Autoincremented",
|
|
||||||
"Natural",
|
|
||||||
"Composite",
|
|
||||||
"Sequential")
|
|
||||||
),
|
|
||||||
"Schema reference" =>
|
|
||||||
array(
|
|
||||||
"Data types" => array(
|
|
||||||
"PHP based types" =>
|
|
||||||
array(
|
|
||||||
"Boolean",
|
|
||||||
"Integer",
|
|
||||||
"Float",
|
|
||||||
"String",
|
|
||||||
"Array",
|
|
||||||
"Object",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
"Basic Components" =>
|
"Basic Components" =>
|
||||||
array(
|
array(
|
||||||
@ -153,6 +144,7 @@ $menu = array("Getting started" =>
|
|||||||
"Getting record state",
|
"Getting record state",
|
||||||
"Getting object copy",
|
"Getting object copy",
|
||||||
"Serializing",
|
"Serializing",
|
||||||
|
"Existence checking",
|
||||||
"Callbacks"),
|
"Callbacks"),
|
||||||
"Connection"
|
"Connection"
|
||||||
=> array("Introduction",
|
=> array("Introduction",
|
||||||
@ -199,6 +191,10 @@ $menu = array("Getting started" =>
|
|||||||
"Using SQL",
|
"Using SQL",
|
||||||
"Adding components",
|
"Adding components",
|
||||||
"Method overloading"),
|
"Method overloading"),
|
||||||
|
"DB" => array(
|
||||||
|
"Introduction",
|
||||||
|
"Connecting to a database",
|
||||||
|
"Using event listeners"),
|
||||||
/**
|
/**
|
||||||
"Statement - <font color='red'>UNDER CONSTRUCTION</font>" => array("Introduction",
|
"Statement - <font color='red'>UNDER CONSTRUCTION</font>" => array("Introduction",
|
||||||
"Setting parameters",
|
"Setting parameters",
|
||||||
@ -263,6 +259,8 @@ $menu = array("Getting started" =>
|
|||||||
"List of events",
|
"List of events",
|
||||||
"Listening events",
|
"Listening events",
|
||||||
"Chaining",
|
"Chaining",
|
||||||
|
"AccessorInvoker",
|
||||||
|
"Creating a logger",
|
||||||
),
|
),
|
||||||
"Validators" => array(
|
"Validators" => array(
|
||||||
"Intruduction",
|
"Intruduction",
|
||||||
@ -275,15 +273,6 @@ $menu = array("Getting started" =>
|
|||||||
"Managing views",
|
"Managing views",
|
||||||
"Using views"
|
"Using views"
|
||||||
),
|
),
|
||||||
/**
|
|
||||||
"Hook" => array(
|
|
||||||
"Introduction",
|
|
||||||
"Parameter hooking",
|
|
||||||
"Paging",
|
|
||||||
"Setting conditions",
|
|
||||||
"Sorting"
|
|
||||||
),
|
|
||||||
*/
|
|
||||||
"Cache" => array(
|
"Cache" => array(
|
||||||
"Introduction",
|
"Introduction",
|
||||||
"Query cache"),
|
"Query cache"),
|
||||||
|
@ -31,15 +31,33 @@ class Doctrine_BooleanTestCase extends Doctrine_UnitTestCase {
|
|||||||
$test = $test->getTable()->find($test->id);
|
$test = $test->getTable()->find($test->id);
|
||||||
$this->assertEqual($test->is_working, true);
|
$this->assertEqual($test->is_working, true);
|
||||||
}
|
}
|
||||||
|
public function testNormalQuerying() {
|
||||||
public function testFetching() {
|
|
||||||
|
|
||||||
$query = new Doctrine_Query($this->connection);
|
$query = new Doctrine_Query($this->connection);
|
||||||
$ret = $query->query('FROM BooleanTest WHERE BooleanTest.is_working = ?', array(false));
|
$ret = $query->query('FROM BooleanTest WHERE BooleanTest.is_working = 0');
|
||||||
$this->assertEqual(count($ret), 1);
|
$this->assertEqual(count($ret), 1);
|
||||||
|
|
||||||
$query = new Doctrine_Query($this->connection);
|
$query = new Doctrine_Query($this->connection);
|
||||||
$ret = $query->query('FROM BooleanTest WHERE BooleanTest.is_working = ?', array(true));
|
$ret = $query->query('FROM BooleanTest WHERE BooleanTest.is_working = 1');
|
||||||
|
Doctrine_Lib::formatSql($query->getQuery());
|
||||||
|
$this->assertEqual(count($ret), 1);
|
||||||
|
}
|
||||||
|
public function testPreparedQueries() {
|
||||||
|
$query = new Doctrine_Query($this->connection);
|
||||||
|
$ret = $query->query('FROM BooleanTest WHERE BooleanTest.is_working = ?', array(false));
|
||||||
|
$this->assertEqual(count($ret), 1);
|
||||||
|
|
||||||
|
$query = new Doctrine_Query($this->connection);
|
||||||
|
$ret = $query->query('FROM BooleanTest WHERE BooleanTest.is_working = ?', array(true));
|
||||||
|
$this->assertEqual(count($ret), 1);
|
||||||
|
}
|
||||||
|
public function testFetchingWithSmartConversion() {
|
||||||
|
$query = new Doctrine_Query($this->connection);
|
||||||
|
$ret = $query->query('FROM BooleanTest WHERE BooleanTest.is_working = false');
|
||||||
|
$this->assertEqual(count($ret), 1);
|
||||||
|
|
||||||
|
$query = new Doctrine_Query($this->connection);
|
||||||
|
$ret = $query->query('FROM BooleanTest WHERE BooleanTest.is_working = true');
|
||||||
|
Doctrine_Lib::formatSql($query->getQuery());
|
||||||
$this->assertEqual(count($ret), 1);
|
$this->assertEqual(count($ret), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class Doctrine_DataDict_Sqlite_TestCase extends Doctrine_UnitTestCase {
|
|||||||
}
|
}
|
||||||
public function testListTables() {
|
public function testListTables() {
|
||||||
$result = $this->dict->listTables();
|
$result = $this->dict->listTables();
|
||||||
|
|
||||||
}
|
}
|
||||||
public function testIntegerType() {
|
public function testIntegerType() {
|
||||||
$this->assertEqual($this->columns['col_int']->isUnique(), false);
|
$this->assertEqual($this->columns['col_int']->isUnique(), false);
|
||||||
|
@ -32,12 +32,11 @@ require_once("ImportTestCase.php");
|
|||||||
require_once("BooleanTestCase.php");
|
require_once("BooleanTestCase.php");
|
||||||
require_once("EnumTestCase.php");
|
require_once("EnumTestCase.php");
|
||||||
require_once("RelationAccessTestCase.php");
|
require_once("RelationAccessTestCase.php");
|
||||||
|
require_once("DataDictSqliteTestCase.php");
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL);
|
||||||
|
|
||||||
$test = new GroupTest("Doctrine Framework Unit Tests");
|
$test = new GroupTest("Doctrine Framework Unit Tests");
|
||||||
|
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_DB_TestCase());
|
$test->addTestCase(new Doctrine_DB_TestCase());
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_ConnectionTestCase());
|
$test->addTestCase(new Doctrine_ConnectionTestCase());
|
||||||
@ -76,9 +75,9 @@ $test->addTestCase(new Doctrine_RawSql_TestCase());
|
|||||||
|
|
||||||
$test->addTestCase(new Doctrine_Query_Limit_TestCase());
|
$test->addTestCase(new Doctrine_Query_Limit_TestCase());
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_SchemaTestCase());
|
//$test->addTestCase(new Doctrine_SchemaTestCase());
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_ImportTestCase());
|
//$test->addTestCase(new Doctrine_ImportTestCase());
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_CollectionTestCase());
|
$test->addTestCase(new Doctrine_CollectionTestCase());
|
||||||
|
|
||||||
@ -93,6 +92,9 @@ $test->addTestCase(new Doctrine_EnumTestCase());
|
|||||||
$test->addTestCase(new Doctrine_RelationAccessTestCase());
|
$test->addTestCase(new Doctrine_RelationAccessTestCase());
|
||||||
|
|
||||||
$test->addTestCase(new Doctrine_EventListener_Chain_TestCase());
|
$test->addTestCase(new Doctrine_EventListener_Chain_TestCase());
|
||||||
|
|
||||||
|
$test->addTestCase(new Doctrine_DataDict_Sqlite_TestCase());
|
||||||
|
|
||||||
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
|
||||||
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
|
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
|
||||||
|
|
||||||
@ -124,9 +126,9 @@ if (TextReporter::inCli()) {
|
|||||||
} else {
|
} else {
|
||||||
if (isset($_POST))
|
if (isset($_POST))
|
||||||
{
|
{
|
||||||
$dsn = $_POST['dsn'];
|
$dsn = isset($_POST['dsn'])?$_POST['dsn']:null;
|
||||||
$username = $_POST['username'];
|
$username = isset($_POST['username'])?$_POST['username']:null;
|
||||||
$password = $_POST['password'];
|
$password = isset($_POST['password'])?$_POST['password']:null;
|
||||||
}
|
}
|
||||||
$test->run(new MyReporter());
|
$test->run(new MyReporter());
|
||||||
$output = ob_get_clean();
|
$output = ob_get_clean();
|
||||||
|
Loading…
Reference in New Issue
Block a user