User: Got User-module working.
[AOOS.git] / model2.php
blob6284dcf1a3134b25a5f68b679df8ff6f07fba580
1 <?php
2 session_start();
3 require_once("AOOSCore.php");
4 require_once("AOOSModel2.php");
5 require_once("AOOSModule.php");
6 require_once("AOOSException.php");
8 function __autoload($class) {
9 $rootfiles = array(
10 "AOOSModule" => "AOOSModule",
11 "AOOSModel" => "AOOSModel2",
12 "AOOSCore" => "AOOSCore",
13 "AOOSException" => "AOOSException",
14 "AOOSTypeException" => "AOOSException",
15 "AOOSLangException" => "AOOSException",
16 "MatchConstraint" => "lib/AOOSModelConstraints"
18 require("settings.php");
20 if (in_array($class, array_keys($rootfiles))) {
21 require_once($rootfiles[$class].$settings["extension"]);
23 elseif (substr($class, 0, 4) == "AOOS") {
24 require_once("lib/".$class.$settings["extension"]);
26 else
27 require_once($settings["module_dir"].$class."/".$class.$settings["extension"]);
30 try {
31 $c = new AOOSCore();
32 $m = new AOOSModel($c);
33 $m->setColumnIndex(array("foo", "bar", "baz"));
34 $m->setSource("mysql");
35 $m->setTable("Test");
37 /* $m->setProperties("foo", AOOSMODEL_TYPE_INTEGER, 0, AOOSMODEL_FLAG_FROM_DATABASE);
38 $m->setProperties("bar", AOOSMODEL_TYPE_STRING, 0, AOOSMODEL_FLAG_FROM_DATABASE);
39 for ($i= 0; $i < 20; $i++) {
40 $m->appendRow(array("bar" => $i, "foo" => $i*2));
41 }*/
43 /* $m->populate(array("foo" => 0));
44 print $m->rows();*/
46 /* $m->addConstraint("bar", "Match", array("/^[a-z0-9]+$/"));
47 $m->addConstraint("foo", "Range", array(5,10));
48 $m->populate();
49 $r = $m->getRow(0);
50 $r->foo = 13;
51 $m->save();
52 print "<hr />";
53 print $m->getRow(0);*/
55 $m->setProperties("foo", AOOSMODEL_TYPE_STRING, AOOSMODEL_PROP_NOHTML, AOOSMODEL_FLAG_UNIQUE);
56 $m->setProperties("bar", AOOSMODEL_TYPE_BOOLEAN);
57 $m->setProperties("baz", AOOSMODEL_TYPE_TEXT, AOOSMODEL_PROP_ESCAPE|AOOSMODEL_PROP_STRIP);
59 $m->appendRow(array(
60 "foo" => "<strong>Her skulle der gerne ikke være html</strong>",
61 "bar" => false,
62 "baz" => " Han sagde 'Denne streng er \"escaped\"!'\t\n "));
63 $m->appendRow(array(
64 "foo" => "<strong>Her skulle der gerne ike være html</strong>",
65 "bar" => false,
66 "baz" => " Han sagde 'Denne streng er \"escaped\"!'\t\n "));
67 print "'".$m->getRow(0)->baz."'";
68 } catch (AOOSException $e) {
69 print $e;