Does Dadabik Differentiate between Views and Tables

bkim

Member
You are runnning the last release of DaDaBIK
PHP Version: 5.6.3
mysql version: 5.6.21
Web server: Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3
Client: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0

I'm trying to create a function that only gets called for views when they update, and I was wondering if dadabik differentiates between views and tables. I'm trying to do this because of the limitations of mysql and views, where you can only update a single table's value within a view.
 

juergen_mueller

DaDaBIK Guru
Hi

I started using views within my dadabik project more often. So far I noticed, dadabik does not visibly differentiate between table and view.

Updating more than one table value via a table view does not seem to be a problem, too.

Juergen
 

bkim

Member
I should specify that the view I am referring to isn't referring to the dadabik table view, but the actual mysql views. The sql error that I get is:
The DBMS server said: SQLSTATE[HY000]: General error: 1393 Can not modify more than one base table through a join view
 

eugenio

Administrator
Staff member
Hello,
as Juergen said, DaDaBIK doesn't Differentiate between tables and views, so the limitations you have with MySQL views remain when you import the view in DaDaBIK.
Can you provide a more precise example?
 

bkim

Member
Well I have a view setup in Dadabik that allows the user to edit the tables that make up the view, tableA and tableB. This view is updatable as there are no aggregate functions, no distincts, group by, having, unions, subqueries, etc. It is essentially:

SELECT tableA.id, tableA.num1, tableB.num2
from tableA
left join tableA on tableA.id = tableB.id

Its set up so that users can create tableA.id and tableB.id from another table so if there is an id in tableA, there will always be a corresponding id in tableB. From there, the user goes in to edit a row in the view and inputs data. When they try to update however, it throws an error because MySQL doesn't allow for the modification of more than one base table in a view.


I was wondering if dadabik could differentiate between views and tables so that I could put in some logic that if it was a view, then it could update each field individually to side step the issue of updating multiple tables at once.

However, if thats not possible, is it possible then for dadabik to only update the fields that have a different value than what was originally in there?
 

eugenio

Administrator
Staff member
For sure I think there is a way to recognize if a table is actually a VIEW using the PDO driver; however, this has not been implemented in DaDaBIK.
If you have just a few cases, why don't you just add an if statement on the table (view) name?
You can find it in the variable $table_name.
 

bkim

Member
Thanks for the idea eugenio! I just modified the update record function in business logic a bit and it works!
 
Top