Changeset 2440

Show
Ignore:
Timestamp:
09/04/08 22:15:50 (3 months ago)
Author:
chrismeller
Message:

Fixed a bug that was throwing a constraint violation on install on a Postgres box. Thanks to enn for the report and debugging help!

Also cleaned up some of jaypipes' SQL blocks. Crazy kids today...

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/htdocs/system/classes/post.php

    r2232 r2440  
    471471        /* Now, let's insert any *new* tag texts or slugs into the tags table */ 
    472472        $repeat_questions= Utils::placeholder_string( count($clean_tags) ); 
    473         $sql_tags_exist=<<<ENDOFSQL 
    474 SELECT id, tag_text, tag_slug 
    475 FROM {tags} 
    476 WHERE tag_text IN ({$repeat_questions}) 
    477 OR tag_slug IN ({$repeat_questions}) 
    478 ENDOFSQL; 
     473        $sql_tags_exist= 'SELECT id, tag_text, tag_slug 
     474            FROM {tags} 
     475            WHERE tag_text IN ({$repeat_questions}) 
     476            OR tag_slug IN ({$repeat_questions})'; 
    479477        $params= array_merge( array_keys( $clean_tags ), array_values( $clean_tags ) ); 
    480478        $existing_tags= DB::get_results( $sql_tags_exist, $params ); 
     
    517515         */ 
    518516        foreach ( $clean_tags as $new_tag_text=>$new_tag_slug ) { 
    519             $sql_tag_new=<<<ENDOFSQL 
    520 INSERT INTO {tags} (id, tag_text, tag_slug) VALUES (NULL, ?, ?) 
    521 ENDOFSQL; 
     517            $sql_tag_new= 'INSERT INTO {tags} (tag_text, tag_slug) VALUES (?, ?)'; 
     518             
    522519            if (FALSE !== ($insert= DB::query( $sql_tag_new, array( $new_tag_text, $new_tag_slug ) ) ) ) 
    523520                $tag_ids_to_post[]= DB::last_insert_id(); 
     
    536533        $post_id= $this->fields['id']; 
    537534        foreach ( $tag_ids_to_post as $index=>$new_tag_id ) { 
    538             $sql_tag_post_exists=<<<ENDOFSQL 
    539 SELECT COUNT(*) FROM {tag2post} WHERE tag_id = ? AND post_id = ? 
    540 ENDOFSQL; 
     535            $sql_tag_post_exists= 'SELECT COUNT(*) FROM {tag2post} WHERE tag_id = ? AND post_id = ?'; 
    541536            if ( 0 == DB::get_value( $sql_tag_post_exists, array( $new_tag_id, $post_id ) ) ) { 
    542               $sql_tag_post_new=<<<ENDOFSQL 
    543 INSERT INTO {tag2post} (tag_id, post_id) VALUES (?, ?) 
    544 ENDOFSQL; 
     537              $sql_tag_post_new= 'INSERT INTO {tag2post} (tag_id, post_id) VALUES (?, ?)'; 
    545538              $result&= DB::query( $sql_tag_post_new, array( $new_tag_id, $post_id ) ); 
    546539            } 
     
    553546             */ 
    554547            $repeat_questions= Utils::placeholder_string( count($tag_ids_to_post) ); 
    555             $sql_delete=<<<ENDOFSQL 
    556 DELETE FROM {tag2post} WHERE post_id = ? AND tag_id NOT IN ({$repeat_questions}); 
    557 ENDOFSQL; 
     548            $sql_delete= 'DELETE FROM {tag2post} WHERE post_id = ? AND tag_id NOT IN ({$repeat_questions})'; 
    558549            $params= array_merge( (array) $post_id, array_values( $tag_ids_to_post ) ); 
    559550            $result&= DB::query( $sql_delete, $params );