| 602 | } |
| 603 | |
| 604 | void IdoPgsqlConnection::InternalActivateObject(const DbObject::Ptr& dbobj) |
| 605 | { |
| 606 | AssertOnWorkQueue(); |
| 607 | |
| 608 | if (!GetConnected()) |
| 609 | return; |
| 610 | |
| 611 | DbReference dbref = GetObjectID(dbobj); |
| 612 | std::ostringstream qbuf; |
| 613 | |
| 614 | if (!dbref.IsValid()) { |
| 615 | if (!dbobj->GetName2().IsEmpty()) { |
| 616 | qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, name2, is_active) VALUES (" |
| 617 | << static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", " |
| 618 | << "'" << Escape(dbobj->GetName1()) << "', '" << Escape(dbobj->GetName2()) << "', 1)"; |
| 619 | } else { |
| 620 | qbuf << "INSERT INTO " + GetTablePrefix() + "objects (instance_id, objecttype_id, name1, is_active) VALUES (" |
| 621 | << static_cast<long>(m_InstanceID) << ", " << dbobj->GetType()->GetTypeID() << ", " |
| 622 | << "'" << Escape(dbobj->GetName1()) << "', 1)"; |
| 623 | } |
| 624 | |
| 625 | IncreasePendingQueries(1); |
| 626 | Query(qbuf.str()); |
| 627 | SetObjectID(dbobj, GetSequenceValue(GetTablePrefix() + "objects", "object_id")); |
| 628 | } else { |
| 629 | qbuf << "UPDATE " + GetTablePrefix() + "objects SET is_active = 1 WHERE object_id = " << static_cast<long>(dbref); |
| 630 | IncreasePendingQueries(1); |
| 631 | Query(qbuf.str()); |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | void IdoPgsqlConnection::DeactivateObject(const DbObject::Ptr& dbobj) |
| 636 | { |