Oznámení
Problém s DibiDataSource a PDO/sqlite3
před 9 lety
- p3s
- Člen | 8
PHP 5.2.8/5.2.13 a dibi 1.2
Ahoj, mam problem s DibiDataSource po prechode z DB sqlite2 na sqlite3 cez PDO.
Uvediem zjednoduseny priklad. Mam testovaciu DB sqlite3:
CREATE TABLE customers (
id integer PRIMARY KEY NOT NULL,
name varchar(200) NOT NULL
);
/* Data for table customers */
INSERT INTO customers (id, name) VALUES (1, 'HP');
INSERT INTO customers (id, name) VALUES (2, 'Acer');
INSERT INTO customers (id, name) VALUES (3, 'Dell');
INSERT INTO customers (id, name) VALUES (4, 'Asus');
INSERT INTO customers (id, name) VALUES (5, 'MSI');
a kod
dibi::connect(array(
'driver' => 'pdo',
'dsn' => 'sqlite:test.sdb3',
));
$ds3 = dibi::select('cus.id, cus.name')
->from('customers')->as('cus')
->toDataSource();
$ds3->orderBy('name');
$ds3->fetchAll();
mi skonci chybou:
DibiDriverException #1
SQLSTATE[HY000]: no such column: name
File: C:\www\nette\libs\dibi\drivers\pdo.php Line: 129
Ladenka hlasi chybu v SQL kode:
SELECT *
FROM (
SELECT cus.id, cus.name
FROM [customers] AS [cus]) t
ORDER BY [name] ASC
(Ak som tento isty kod pouzil nad sqlite2 DB vsetko bolo OK. Je tiez zaujimave ze ked kod z Ladenky pustim v SQL manageri tiez je to ok.)
Ak vynecham riadok $ds3->orderBy('name');
chybu nehlasi, tiez
ako pouzijem zapis stlpcov bez aliasu.
..
$ds3 = dibi::select('id, name')->from('customers')->as('cus')->toDataSource();
..
Pri komplexnejsich dotazoch kde sa joinuju viacere tabulky sa vsak bez aliasov nezaobidem a tym padom je DibiDataSource nepouzitelne. Nestretol sa niekto z vas s podobnym problemom?
Diky.
před 9 lety
- David Grudl
- Nette Core | 6806
Nefungovalo by tohle?
$ds3->orderBy('cus.name');