X-Git-Url: http://git.ithinksw.org/extjs.git/blobdiff_plain/ee06f37b0f6f6d94cd05a6ffae556660f7c4a2bc..c930e9176a5a85509c5b0230e2bff5c22a591432:/examples/image-organizer/php/sql/setup.php diff --git a/examples/image-organizer/php/sql/setup.php b/examples/image-organizer/php/sql/setup.php new file mode 100644 index 00000000..a26fe3cd --- /dev/null +++ b/examples/image-organizer/php/sql/setup.php @@ -0,0 +1,72 @@ +queryExec('DROP TABLE Albums'); + $db->queryExec('CREATE TABLE Albums ( + id INTEGER PRIMARY KEY, + text STRING, + created STRING, + description TEXT + ); + INSERT INTO Albums (text) VALUES ("Test"); + INSERT INTO Albums (text) VALUES ("Album2");'); + + // Albums_Images +// $db->queryExec('DROP TABLE Albums_Images'); + $db->queryExec('CREATE TABLE Albums_Images ( + album_id INTEGER, + image_id INTEGER + )'); + + // Images_Tags + $db->queryExec('CREATE TABLE Images_Tags ( + tag_id INTEGER, + image_id INTEGER + )'); + + // Tags +// $db->queryExec('DROP Table Tags'); + $db->queryExec('CREATE TABLE Tags ( + id INTEGER PRIMARY KEY, + text STRING + ); + INSERT INTO Tags (text) VALUES("Family"); + INSERT INTO Tags (text) VALUES("Friends"); + INSERT INTO Tags (text) VALUES("Other")'); + + // Images +// $db->queryExec('DROP TABLE Images'); + $db->queryExec('CREATE TABLE Images ( + id INTEGER PRIMARY KEY, + filename STRING, + url STRING, + album_id INTEGER, + description TEXT + )'); + +// $dir = "../../images/thumbs/"; +// $images = array(); +// $d = dir($dir); +// $i = 0; +// while($name = $d->read()){ +// if(!preg_match('/\.(jpg|gif|png)$/', $name)) continue; +// $size = filesize($dir.$name); +// $lastmod = filemtime($dir.$name)*1000; +// $db->queryExec('INSERT INTO Images (filename, url) VALUES +// ("'.$name.'","images/thumbs/'.$name.'")'); +// } +// $d->close(); + + + echo json_encode($db->query('select * from Images')->fetchAll()); + } else { + die($err); + } +