Add pagenator to contact list

Move contacts from plugin back to core
This commit is contained in:
RainLoop Team 2013-12-08 03:58:33 +04:00
parent daa958ed44
commit 0ec4fc89d4
44 changed files with 1250 additions and 889 deletions

View file

@ -9,6 +9,11 @@ abstract class PdoAbstract
*/
protected $oPDO = null;
/**
* @var bool
*/
protected $bExplain = false;
/**
* @var \MailSo\Log\Logger
*/
@ -130,22 +135,26 @@ abstract class PdoAbstract
}
/**
* @param \RainLoop\Account $oAccount
* @param string $sSql
* @param array $aParams
* @param bool $bMultParams = false
* @param bool $bMultiplyParams = false
*
* @return \PDOStatement|null
*/
protected function prepareAndExecute($sSql, $aParams = array(), $bMultParams = false)
protected function prepareAndExecute($sSql, $aParams = array(), $bMultiplyParams = false)
{
if ($this->bExplain && !$bMultiplyParams)
{
$this->prepareAndExplain($sSql, $aParams);
}
$mResult = null;
$this->writeLog($sSql);
$oStmt = $this->getPDO()->prepare($sSql);
if ($oStmt)
{
$aRootParams = $bMultParams ? $aParams : array($aParams);
$aRootParams = $bMultiplyParams ? $aParams : array($aParams);
foreach ($aRootParams as $aSubParams)
{
foreach ($aSubParams as $sName => $aValue)
@ -153,12 +162,45 @@ abstract class PdoAbstract
$oStmt->bindValue($sName, $aValue[0], $aValue[1]);
}
$mResult = $oStmt->execute() && !$bMultParams ? $oStmt : null;
$mResult = $oStmt->execute() && !$bMultiplyParams ? $oStmt : null;
}
}
return $mResult;
}
/**
* @param string $sSql
* @param array $aParams
*/
protected function prepareAndExplain($sSql, $aParams = array())
{
$mResult = null;
if (0 === strpos($sSql, 'SELECT '))
{
$sSql = 'EXPLAIN '.$sSql;
$this->writeLog($sSql);
$oStmt = $this->getPDO()->prepare($sSql);
if ($oStmt)
{
foreach ($aParams as $sName => $aValue)
{
$oStmt->bindValue($sName, $aValue[0], $aValue[1]);
}
$mResult = $oStmt->execute() ? $oStmt : null;
}
}
if ($mResult)
{
$aFetch = $mResult->fetchAll(\PDO::FETCH_ASSOC);
$this->oLogger->WriteDump($aFetch);
unset($aFetch);
$mResult->closeCursor();
}
}
/**
* @param string $sSql