Jak presne funguje iterace DibiDataSource a jak vpravit dalsi atribut do result?
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- Ja
- Člen | 260
(lame alert)
Ahoj,
kdyz si dumpnu objekt, napr promennou $ds, kde je dibi datasource:
<?php
DibiDataSource(10) {
connection private => DibiConnection(6) {
config private => array(10) {
driver => "mysql" (5)
host => "localhost" (9)
database => "db" (6)
password => "root" (4)
profiler => TRUE
username => "root" (4)
result => array(2) { ... }
name => 0
flags => NULL
charset => "utf8" (4)
}
driver private => DibiMySqlDriver(3) {
connection private => mysql link resource
resultSet private => NULL
buffered private => TRUE
}
translator private => DibiTranslator(11) {
connection private => DibiConnection(6) { *RECURSION* }
driver private => DibiMySqlDriver(3) { ... }
cursor private => 1
args private => array(1) [ ... ]
hasError private => FALSE
comment private => FALSE
ifLevel private => 0
ifLevelStart private => 0
limit private => -1
offset private => 0
identifiers private => DibiHashMap(1) { ... }
}
profiler private => DibiProfiler(4) {
file private => NULL
useFirebug => FALSE
explainQuery => TRUE
filter private => 1023
}
connected private => TRUE
substitutes private => DibiHashMap(2) {
callback private => "\x00lambda_3166" (12)
pre => "vc_" (3)
}
}
sql private => "(
dotaz
) t" (141)
result private => NULL
count private => NULL
totalCount private => NULL
cols private => array(0)
sorting private => array(0)
conds private => array(0)
offset private => NULL
limit private => NULL
}
?>
jaktoze pri iteraci
<?php
foreach($ds as $item)
$item->polozka;
?>
se k tem polozkam pohodlne dostanu, ackoli pres tu strukturu v dumpu toho nejsem schopen?
Vysledkem by totiz melo byt, ze potrebuju php skriptem si dopocitat jeden atribut a ten tam do toho datasource nejakym zpusobem vpravit – neco jako toto $ds->result[0]->nova_polozka = vysledek; a plus teda i vysledkem by melo byt lepsi pochopeni, jak tato iterace vlastne presne funguje (tj. jak vi nad cim ma presne ten foreach iterovat)
muze mi to prosim nekdo trosku osvetlit? Diky moc.
Ja
- Jan Tvrdík
- Nette guru | 2595
- Jan Tvrdík
- Nette guru | 2595
Co je $ds
, co je result? Pokud je result public property objektu
$ds typu array obsahující pod klíčem 0 instanci stdClass, tak to bude
fungovat :)