Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion core/DB/MyDialect.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ public function fullTextSearch($fields, $words, $logic)
.self::prepareFullText($words, $logic)
.')';
}

public static function toCasted($field, $type)
{
return "CAST({$field} AS {$type})";
}

private static function prepareFullText($words, $logic)
{
Expand All @@ -133,4 +138,4 @@ private static function prepareFullText($words, $logic)
}
}
}
?>
?>
36 changes: 36 additions & 0 deletions test/core/MyDialectTest.class.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
/**
* @author Artem Naumenko <[email protected]>
* @copyright Copyright (c) 2012, Wapstart
*/
final class MyDialectTest extends TestCase
{
public function setUp()
{
if (!extension_loaded('mysql'))
$this->markTestSkipped('Install mysql extension');

try {
$link = DB::spawn('MySQL', 'root', '', 'localhost');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Есть конфиг файл с адресами баз в каком-то виде. А тут вообще жёстко так захардкожено.

$link->connect();
DBPool::me()->addLink('test', $link);
} catch (Exception $e) {
$this->markTestSkipped("Can't connect to MySQL on localhost");
}
}

public function testCastTo()
{
$result =
DBPool::me()->getLink('test')->queryRow(
OSQL::select()->
get(
DBValue::create('12')->
castTo('decimal(5, 3)'),
'test'
)
);

$this->assertEquals($result['test'], '12.000');
}
}