-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #200 from thecodingmachine/fix/findFromRaxSql-count
findFromRaw sql count
- Loading branch information
Showing
5 changed files
with
114 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
namespace TheCodingMachine\TDBM\Dao; | ||
|
||
use TheCodingMachine\TDBM\Test\Dao\Bean\AlbumBean; | ||
use TheCodingMachine\TDBM\Test\Dao\Generated\AlbumBaseDao; | ||
|
||
/** | ||
* The AlbumDao class will maintain the persistence of UserBean class into the users table. | ||
*/ | ||
class TestAlbumDao extends AlbumBaseDao | ||
{ | ||
/** | ||
* @return \TheCodingMachine\TDBM\ResultIterator|AlbumBean[] | ||
*/ | ||
public function findAllFromRawSql() | ||
{ | ||
return $this->findFromRawSql('SELECT DISTINCT albums.* FROM albums'); | ||
} | ||
|
||
/** | ||
* @return \TheCodingMachine\TDBM\ResultIterator|AlbumBean[] | ||
*/ | ||
public function findAllFromRawSqlWithCount() | ||
{ | ||
return $this->findFromRawSql( | ||
'SELECT DISTINCT albums.* FROM albums', | ||
[], | ||
'SELECT COUNT(DISTINCT albums.id) FROM albums' | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/* | ||
* This file has been automatically generated by TDBM. | ||
* You can edit this file as it will not be overwritten. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace TheCodingMachine\TDBM\Dao; | ||
|
||
use TheCodingMachine\TDBM\ResultIterator; | ||
use TheCodingMachine\TDBM\Test\Dao\Generated\PersonBaseDao; | ||
|
||
/** | ||
* The ContactDao class will maintain the persistence of ContactBean class into the contact table. | ||
*/ | ||
class TestPersonDao extends PersonBaseDao | ||
{ | ||
public function testFindFromRawSQLOnInherited(): ResultIterator | ||
{ | ||
$sql = ' | ||
SELECT DISTINCT person.*, contact.*, users.* | ||
FROM person JOIN contact ON person.id = contact.id | ||
JOIN users ON contact.id = users.id | ||
'; | ||
|
||
return $this->findFromRawSql($sql, []); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters