@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | $this->logger = $logger; |
| 47 | 47 | } |
| 48 | 48 | $this->apiLimitInsertUpdateDelete = $apiLimitInsertUpdateDelete; |
| 49 | - if($apiLimitInsertUpdateDelete === null){ |
|
| 49 | + if ($apiLimitInsertUpdateDelete === null) { |
|
| 50 | 50 | $this->apiLimitInsertUpdateDelete = 100; |
| 51 | 51 | } |
| 52 | 52 | } |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $rowsDeleted = []; |
| 90 | 90 | //@see https://www.zoho.com/crm/help/api/api-limits.html |
| 91 | 91 | //To optimize your API usage, get maximum 200 records with each request and insert, update or delete maximum 100 records with each request. |
| 92 | - do{ |
|
| 92 | + do { |
|
| 93 | 93 | $statementLimiter = $this->connection->createQueryBuilder(); |
| 94 | 94 | $statementLimiter->select('DISTINCT table_name,uid') |
| 95 | 95 | ->from($localTable)->setMaxResults($this->apiLimitInsertUpdateDelete); |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | $statement->addSelect('l.field_name as updated_fieldname'); |
| 100 | 100 | } |
| 101 | 101 | $statement->from($localTable, 'l') |
| 102 | - ->join('l','('.$statementLimiter->getSQL().')','ll','ll.table_name = l.table_name and ll.uid = l.uid') |
|
| 102 | + ->join('l', '('.$statementLimiter->getSQL().')', 'll', 'll.table_name = l.table_name and ll.uid = l.uid') |
|
| 103 | 103 | ->join('l', $tableName, 'zcrm', 'zcrm.uid = l.uid') |
| 104 | 104 | ->where('l.table_name=:table_name') |
| 105 | 105 | ->setParameters([ |
@@ -131,9 +131,9 @@ discard block |
||
| 131 | 131 | $rowsDeleted[] = $row['uid']; |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | - $this->sendDataToZohoCleanLocal($zohoDao,$zohoBeans,$rowsDeleted,$update); |
|
| 135 | - $countElementToPush = $statementLimiter->select('DISTINCT table_name,uid')->from($localTable)->execute()->rowCount(); |
|
| 136 | - } while($countElementToPush > 0); |
|
| 134 | + $this->sendDataToZohoCleanLocal($zohoDao, $zohoBeans, $rowsDeleted, $update); |
|
| 135 | + $countElementToPush = $statementLimiter->select('DISTINCT table_name,uid')->from($localTable)->execute()->rowCount(); |
|
| 136 | + } while ($countElementToPush > 0); |
|
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | /** |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param string[] $rowsDeleted |
| 143 | 143 | * @param bool $update |
| 144 | 144 | */ |
| 145 | - private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans,$rowsDeleted, $update = false) |
|
| 145 | + private function sendDataToZohoCleanLocal(AbstractZohoDao $zohoDao, array $zohoBeans, $rowsDeleted, $update = false) |
|
| 146 | 146 | { |
| 147 | 147 | $tableName = ZohoDatabaseHelper::getTableName($zohoDao, $this->prefix); |
| 148 | 148 | $zohoDao->save($zohoBeans); |
@@ -154,13 +154,13 @@ discard block |
||
| 154 | 154 | // ID not exist we can update the new row with the Zoho ID |
| 155 | 155 | $this->connection->beginTransaction(); |
| 156 | 156 | $this->connection->update($tableName, ['id' => $zohoBean->getZohoId()], ['uid' => $uid]); |
| 157 | - $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]); |
|
| 157 | + $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]); |
|
| 158 | 158 | $this->connection->commit(); |
| 159 | 159 | } else { |
| 160 | 160 | //ID already exist we need to delete the duplicate row. |
| 161 | 161 | $this->connection->beginTransaction(); |
| 162 | - $this->connection->delete($tableName, ['uid' => $uid ]); |
|
| 163 | - $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid ]); |
|
| 162 | + $this->connection->delete($tableName, ['uid' => $uid]); |
|
| 163 | + $this->connection->delete('local_insert', ['table_name'=>$tableName, 'uid' => $uid]); |
|
| 164 | 164 | $this->connection->commit(); |
| 165 | 165 | } |
| 166 | 166 | } |