Ejemplo n.º 1
0
    public static function getLoadSql()
    {
        $tableName = Book2library::getTableName();
        return '
			SELECT
				`' . $tableName . '`.*
				, ' . implode("\n\t\t\t\t, ", CoughObject::getFieldAliases('Book', 'Book_Object', 'book')) . '
				, ' . implode("\n\t\t\t\t, ", CoughObject::getFieldAliases('Library', 'Library_Object', 'library')) . '
			FROM
				`' . Book2library::getDbName() . '`.`' . $tableName . '`
				INNER JOIN `' . Book::getDbName() . '`.`' . Book::getTableName() . '` AS `book`
					ON `' . $tableName . '`.`book_id` = `book`.`book_id`
				INNER JOIN `' . Library::getDbName() . '`.`' . Library::getTableName() . '` AS `library`
					ON `' . $tableName . '`.`library_id` = `library`.`library_id`
		';
    }
Ejemplo n.º 2
0
 /**
  * Constructs a new Miss object from custom SQL.
  * 
  * @param string $sql
  * @return mixed - Miss or null if exactly one record could not be found.
  **/
 public static function constructBySql($sql, $forPhp5Strict = '')
 {
     return CoughObject::constructBySql($sql, 'Miss');
 }
Ejemplo n.º 3
0
    public function loadBook2library_Collection()
    {
        // Always create the collection
        $collection = new Book2library_Collection();
        $this->setBook2library_Collection($collection);
        // But only populate it if we have key ID
        if ($this->hasKeyId()) {
            $db = Book2library::getDb();
            $tableName = Book2library::getTableName();
            $sql = '
				SELECT
					`' . $tableName . '`.*
					, ' . implode("\n\t\t\t\t\t, ", CoughObject::getFieldAliases('Library', 'Library_Object', 'library')) . '
				FROM
					`' . Book2library::getDbName() . '`.`' . $tableName . '`
					INNER JOIN `' . Library::getDbName() . '`.`' . Library::getTableName() . '` AS `library`
						ON `' . $tableName . '`.`library_id` = `library`.`library_id`
				WHERE
					`' . $tableName . '`.`book_id` = ' . $db->quote($this->getBookId()) . '
			';
            // Construct and populate the collection
            $collection->loadBySql($sql);
            foreach ($collection as $element) {
                $element->setBook_Object($this);
            }
        }
    }
Ejemplo n.º 4
0
 /**
  * Adds a single element (even if it doesn't have a key ID yet).
  * 
  * @param CoughObject $object
  * @return void
  * @author Anthony Bush
  **/
 public function add(CoughObject $object)
 {
     if ($object->hasKeyId()) {
         $this->offsetSet($object->getKeyId(), $object);
     } else {
         $this->offsetSet(CoughCollection::getTemporaryKey(), $object);
     }
 }