/** * thực thi một câu sql nếu table chưa tồn tại thì tạo table và thực thi lại câu sql * * @param string $strExecuteQuery câu sql muốn thực thi * @param string $strCommand câu lệnh tạo table * @param object $objConnection connect to db * @param string $strCheckTable tên của table * @return bool true thành công, false thất bại * */ public function ExecutequeryWithCheckExistedTable($strExecuteQuery, $strCommand, $objConnection, $strCheckTable) { if (!$strExecuteQuery) { return false; } // Execute query $result1 = $objConnection->executeSQL($strExecuteQuery); if ($result1 == -1) { $errorCode = $objConnection->getErrorCode(); if ($errorCode == global_common::ERR_TABLE_NOT_EXIST || $errorCode == global_common::ERR_TABLE_UNKNOWN || $errorCode == global_common::ERR_INSERT_DUPLICATED || !global_common::isTableExisted($objConnection, $strCheckTable)) { $strCreateTable = global_common::prepareQuery($strCommand, array($strCheckTable)); if ($objConnection->executeSQL($strCreateTable) == -1) { return false; } if ($objConnection->executeSQL($strExecuteQuery) == -1) { return false; } } else { return false; } } return true; }