booleanise relationships
This commit is contained in:
parent
ed64cea8f6
commit
19d85e415d
1 changed files with 7 additions and 7 deletions
|
@ -31,19 +31,20 @@ class Relationships extends Extension
|
|||
{
|
||||
global $database;
|
||||
|
||||
// Create the database tables
|
||||
if ($this->get_version("ext_relationships_version") < 1) {
|
||||
$database->execute("ALTER TABLE images ADD parent_id INT");
|
||||
$database->execute($database->scoreql_to_sql("ALTER TABLE images ADD has_children SCORE_BOOL DEFAULT SCORE_BOOL_N NOT NULL"));
|
||||
$database->execute("ALTER TABLE images ADD has_children BOOLEAN DEFAULT FALSE NOT NULL");
|
||||
$database->execute("CREATE INDEX images__parent_id ON images(parent_id)");
|
||||
|
||||
$this->set_version("ext_relationships_version", 1);
|
||||
}
|
||||
if ($this->get_version("ext_relationships_version") < 2) {
|
||||
$database->execute("CREATE INDEX images__has_children ON images(has_children)");
|
||||
|
||||
$this->set_version("ext_relationships_version", 2);
|
||||
}
|
||||
if ($this->get_version("ext_relationships_version") < 3) {
|
||||
$database->standardise_boolean("images", "has_children");
|
||||
$this->set_version("ext_relationships_version", 3);
|
||||
}
|
||||
}
|
||||
|
||||
public function onImageInfoSet(ImageInfoSetEvent $event)
|
||||
|
@ -204,9 +205,8 @@ class Relationships extends Extension
|
|||
["pid"=>$parent_id]
|
||||
);
|
||||
$database->execute(
|
||||
"UPDATE images
|
||||
SET has_children = :has_children WHERE id = :pid",
|
||||
["has_children"=>$database->scoresql_value_prepare($children>0), "pid"=>$parent_id]
|
||||
"UPDATE images SET has_children = :has_children WHERE id = :pid",
|
||||
["has_children"=>$children>0, "pid"=>$parent_id]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue