mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merging fixes and enhancements into trunk
Revision: [1927] A little refactoring on the findBy<field> and findAllBy<field>. These should both work on PHP 4 now without an issue. Change the condition to be built as an array in DboMysql::query(). Still want to refactor the DboSource::conditions() which is note around line 1058 TODO: git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1928 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
c2dcc10996
commit
cd2d68a6c8
3 changed files with 9 additions and 8 deletions
|
@ -6,4 +6,4 @@
|
||||||
// +---------------------------------------------------------------------------------------------------+ //
|
// +---------------------------------------------------------------------------------------------------+ //
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
0.10.8.1926 RC 4
|
0.10.8.1928 RC 4
|
|
@ -518,7 +518,6 @@ class DboSource extends DataSource
|
||||||
foreach ($resultSet as $i => $row)
|
foreach ($resultSet as $i => $row)
|
||||||
{
|
{
|
||||||
$q = $this->insertQueryData($query, $resultSet, $association, $assocData, $model, $linkModel, $i);
|
$q = $this->insertQueryData($query, $resultSet, $association, $assocData, $model, $linkModel, $i);
|
||||||
//pr($q);
|
|
||||||
$fetch = $this->fetchAll($q);
|
$fetch = $this->fetchAll($q);
|
||||||
|
|
||||||
if (!empty($fetch) && is_array($fetch))
|
if (!empty($fetch) && is_array($fetch))
|
||||||
|
|
|
@ -149,20 +149,22 @@ class DboMysql extends DboSource
|
||||||
function query ()
|
function query ()
|
||||||
{
|
{
|
||||||
$args = func_get_args();
|
$args = func_get_args();
|
||||||
|
|
||||||
if (count($args) == 1)
|
if (count($args) == 1)
|
||||||
{
|
{
|
||||||
return $this->fetchAll($args[0]);
|
return $this->fetchAll($args[0]);
|
||||||
}
|
}
|
||||||
elseif (count($args) > 1 && strpos($args[0], 'findBy') === 0)
|
elseif (count($args) > 1 && strpos(low($args[0]), 'findby') === 0)
|
||||||
{
|
{
|
||||||
$field = Inflector::underscore(str_replace('findBy', '', $args[0]));
|
$field = Inflector::underscore(preg_replace('/findBy/i', '', $args[0]));
|
||||||
$query = '`' . $args[2]->name . '`.`' . $field . '` = ' . $this->value($args[1][0]);
|
$query = array($args[2]->name.'.'.$field => $args[1][0]);
|
||||||
|
|
||||||
return $args[2]->find($query);
|
return $args[2]->find($query);
|
||||||
}
|
}
|
||||||
elseif (count($args) > 1 && strpos($args[0], 'findAllBy') === 0)
|
elseif (count($args) > 1 && strpos(low($args[0]), 'findallby') === 0)
|
||||||
{
|
{
|
||||||
$field = Inflector::underscore(str_replace('findAllBy', '', $args[0]));
|
$field = Inflector::underscore(preg_replace('/findAllBy/i', '', $args[0]));
|
||||||
$query = '`' . $args[2]->name . '`.`' . $field . '` = ' . $this->value($args[1][0]);
|
$query = array($args[2]->name.'.'.$field => $args[1][0]);
|
||||||
return $args[2]->findAll($query);
|
return $args[2]->findAll($query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue