# |
Mar 29th 2019, 13:45 |
ricksaccous |
what about |
# |
Mar 29th 2019, 13:44 |
liaogz82 |
no it is not there |
# |
Mar 29th 2019, 13:44 |
ricksaccous |
in your code find $this->loadComponent('CSRF'); or whatever it's called |
# |
Mar 29th 2019, 13:44 |
ricksaccous |
;) |
# |
Mar 29th 2019, 13:44 |
ricksaccous |
it is loaded somewhere |
# |
Mar 29th 2019, 13:41 |
liaogz82 |
is there a way to turn it off? |
# |
Mar 29th 2019, 13:41 |
liaogz82 |
no i did not load it in AppController |
# |
Mar 29th 2019, 13:40 |
ricksaccous |
just don't load component if it's api request |
# |
Mar 29th 2019, 13:40 |
ricksaccous |
CSRF is a component isn't it? |
# |
Mar 29th 2019, 13:38 |
liaogz82 |
it seems to be default on |
# |
Mar 29th 2019, 13:37 |
liaogz82 |
how do i do that? |
# |
Mar 29th 2019, 13:35 |
admad |
JSON APIs can't have CSRF problem. Just turn of CSRF check for API urls |
# |
Mar 29th 2019, 13:33 |
liaogz82 |
and I am using API calls with no authentication |
# |
Mar 29th 2019, 13:32 |
liaogz82 |
i have no problems with index but i have a lot of problems with add |
# |
Mar 29th 2019, 13:31 |
liaogz82 |
i been using cake 3.7 and been facing CSRF problems https://github.com/FriendsOfCake/crud-json-api/issues/96 |
# |
Mar 29th 2019, 13:31 |
liaogz82 |
hi guys |
# |
Mar 29th 2019, 13:30 |
admad |
or use Controller::setTableLocator() |
# |
Mar 29th 2019, 13:29 |
admad |
actually can just set `Controller::$_tableLocator` instead |
# |
Mar 29th 2019, 13:28 |
admad |
@val make your own locator class by extending core's `TableLocator`. Then use Controller::modelFactory() to set your locator as for model of type "Table" |
# |
Mar 29th 2019, 13:26 |
joopm |
but i have issue because i have an error the Call to undefined method viewBuilder |
# |
Mar 29th 2019, 13:25 |
joopm |
my component is extends from Component |
# |
Mar 29th 2019, 13:25 |
joopm |
i would like to use he viewbuilder in a component controller |
# |
Mar 29th 2019, 13:25 |
joopm |
hello there |
# |
Mar 29th 2019, 13:21 |
val |
Would it be possible to configure `TableLocator` to change `$config` params passed to `Table` constructor? |
# |
Mar 29th 2019, 13:12 |
admad |
it isn't used under actual query is generated |
# |
Mar 29th 2019, 13:12 |
admad |
you should be able to switch table name even after model is constructed |
# |
Mar 29th 2019, 13:11 |
val |
https://api.cakephp.org/3.6/class-Cake.ORM.Table.html#___construct seems to support `$config['table']` parameter |
# |
Mar 29th 2019, 13:10 |
val |
ok, that might work when the model is already constructed. how would it be possible to do something similar before the model is constructed? I mean to pass the table name to the model constructor. |
# |
Mar 29th 2019, 13:05 |
admad |
or rather getTable()/setTable() to prefix db/schema name to the table |
# |
Mar 29th 2019, 13:02 |
admad |
you can try tinkering with Table::getAlias() / setAlias() |
# |
Mar 29th 2019, 12:58 |
admad |
i can't remember off top of my head what's the method which handles that |
# |
Mar 29th 2019, 12:58 |
val |
@spriz nope, no subdomains |
# |
Mar 29th 2019, 12:58 |
admad |
@val right, you can prefix the db names to tables/aliases |
# |
Mar 29th 2019, 12:58 |
spriz |
@val do each customer not have their own subdomain or something like that? In that case you’d need to only get that single subdomain |
# |
Mar 29th 2019, 12:56 |
val |
@admad well, in cake 2.x this can be done by prefixing the table name with the schema name. F.ex. `$DataSource->buildStatement([..., 'table' => 'db_1.orders_table'], $this)`. |
# |
Mar 29th 2019, 12:49 |
admad |
yeah you can't stuff like that when using an abstraction layer |
# |
Mar 29th 2019, 12:47 |
val |
`db_main`, `db_1`, `db_2` are different databases. |
# |
Mar 29th 2019, 12:46 |
val |
A very simplified example in MySQL: `USE db_main; SELECT * from db_main.customers; SELECT * from db_1.orders_table; SELECT * from db_2.orders_table;` |
# |
Mar 29th 2019, 12:46 |
admad |
db name is specified when PDO object is created |
# |
Mar 29th 2019, 12:44 |
val |
@admad so, technically the database connection is the same, but the schema name is not |
# |
Mar 29th 2019, 12:43 |
val |
@admad iterating 1000 customers and creating 1000 connections is not viable. We do switch the schema name on the fly in 2.x but in a quite a hacky way. So, I hoped it would be easier in 3.x. |