Exemplo n.º 1
0
$db->pln($db->select("authors", ['fl' => 'id, name,xid', 'where' => 'id=1']), "name,xid");
$db->pln($db->select("authors", ['fl' => $iArray, 'type' => 'num', 'where' => 'id=1']), "num");
$db->pln($db->select("books", ['where' => 'id<3']), "assoc");
$db->pln($db->select("books", ['where' => 'id<3', 'all' => 'all']), "all-assoc");
$db->pln($db->dbRow("authors", ['where' => 'id=1']), 'dbRow');
$db->pln($db->dbField("authors", "name", 'id=1'), 'dbFieldValue');
// schema test case
$fields = $db->fieldsKey("authors", "_none");
$db->pln($fields, "schema", 'p');
$one = $db->filterBySchema("authors", $iArray);
$db->pln($one, "schema filter");
$db->pln($db->getNextId("books", "id"), "next books id");
// array to string
$db->pln($db->a2sSelect($one), "select");
$db->pln($db->a2sInsert($one), "insert");
$db->pln($db->a2sUpdate($one), "update");
$db->pln($db->a2sSelect($iArray), "select");
// old test case
$sql = $db->qbSelect("books", ['where' => "id <3"]);
$db->pln($sql, "sql");
echo "<p />Samples use object _call dbFetch";
$db->pln($db->row2Array($sql), "row2array-num");
$db->pln($db->row2Array($sql, "assoc"), "row2array-assoc");
$db->pln($db->dbFetchAssoc($db->query($sql)), "dbFetchAssoc");
echo "<br />Samples use static __callStatic dbFetch: ";
$db->pln(PdoLite::dbFetchRow(PdoLite::query($sql)), "row");
$arr = PdoLite::dbFetchArray(PdoLite::query($sql));
$db->pln($arr, "both");
$db->pln(array_values($arr), "value");
$sql = $db->qbSelect("books", ['where' => "id <3"]);
echo "<p />dbFetch obj: ";