示例#1
0
 public function mark($mark_as, $object_or_action, $ID, $TxnID_or_ListID = null, $errnum = null, $errmsg = null, $mark_as_dequeued = true)
 {
     $Driver = $this->_driver;
     $object = QuickBooks_Utilities::actionToObject($object_or_action);
     $table_and_field = array();
     // Convert to table and primary key, select qbsql id
     QuickBooks_SQL_Schema::mapPrimaryKey($object, QUICKBOOKS_SQL_SCHEMA_MAP_TO_SQL, $table_and_field);
     if (!empty($table_and_field[0]) and !empty($table_and_field[1])) {
         switch ($mark_as) {
             case QuickBooks_Map::MARK_ADD:
                 $arr = array();
                 $where = array(array(QUICKBOOKS_DRIVER_SQL_FIELD_ID => $ID));
                 if ($TxnID_or_ListID) {
                     $arr[$table_and_field[1]] = $TxnID_or_ListID;
                     // Get the existing temporary ID
                     $errnum = null;
                     $errmsg = null;
                     $existing = $Driver->fetch($Driver->query("SELECT " . $table_and_field[1] . " FROM " . QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table_and_field[0] . " WHERE " . QUICKBOOKS_DRIVER_SQL_FIELD_ID . " = " . $ID, $errnum, $errmsg));
                     if (!$existing) {
                         return false;
                     }
                     $existing_TxnID_or_ListID = $existing[$table_and_field[1]];
                 }
                 $resync = true;
                 $discov = true;
                 if ($errnum) {
                     $arr[QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_NUMBER] = $errnum;
                     $arr[QUICKBOOKS_DRIVER_SQL_FIELD_ERROR_MESSAGE] = $errmsg;
                     // Don't mark it as synced/discovered if there was an error
                     $resync = false;
                     $discov = false;
                 }
                 /*
                 if ($mark_as_dequeued)
                 {
                 	$arr[QUICKBOOKS_DRIVER_SQL_FIELD_ENQUEUE_TIME] = date('Y-m-d H:i:s');
                 }
                 */
                 $Driver->update(QUICKBOOKS_DRIVER_SQL_PREFIX_SQL . $table_and_field[0], $arr, $where, $resync, $discov);
                 if ($TxnID_or_ListID) {
                     $Object = new QuickBooks_SQL_Object($table_and_field[0], '', array());
                     $Object->set($table_and_field[1], $TxnID_or_ListID);
                     $action = QuickBooks_Utilities::objectToAdd($object_or_action);
                     $this->_updateRelatives($table_and_field[0], $action, $Object, $existing_TxnID_or_ListID);
                 }
                 break;
         }
     }
     return false;
 }