Base table or view not found (user table is a linked table)

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
lissa
User
Posts: 73

Base table or view not found (user table is a linked table)

Post by lissa »

Hi,
I want to ask, I found an error like this when I set advanced setting - user ID - t_orders - id_orders.
I use linked tables.
when I remove id_orders from user ID there is no problem?
how to make 'SELECT id_order...' like SELECT db_data_center.t_orders.id_order...'

Error : D:\XAMPP\htdocs\project1\vendor\doctrine\dbal\src\Driver\API\MySQL\ExceptionConverter.php(49): An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db_data_center.t_orders' doesn't exist

debug result :

#0 D:\XAMPP\htdocs\project1\vendor \doctrine\dbal\src\Connection.php(1939): Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert(Object(Doctrine\DBAL\Driver\PDO\Exception), Object(Doctrine\DBAL\Query)) 
#1 D:\XAMPP\htdocs\project1\vendor\doctrine\dbal\src\Connection.php(1881): Doctrine\DBAL\Connection->handleDriverException(Object(Doctrine\DBAL\Driver\PDO\Exception), Object(Doctrine\DBAL\Query)) 
#2 D:\XAMPP\htdocs\project1\vendor\doctrine\dbal\src\Connection.php(1 106): Doctrine\DBAL\Connection->convertExceptionDuringQuery(Object(Doctrine\DBAL\Driver\PDO\Exception), 'SELECT `id_order...', Array, Array) 
#3 D:\XAMPP\htdocs\project1\vendor\doctrine\dbal\src\Connection.php(902): Doctrine\DBAL\Connection->executeQuery('SELECT `order_id...', Array, Array) 
#4 D:\XAMPP\htdocs\project1\vendor\doctrine\dbal\src\Connection.php(1152): Doctrine\DBAL\Connection->fetchAllAssociative('SELECT `order_id...', Array, Array) 
#5 D:\XAMPP\htdocs\project1\models\TOrders.php(1642): rine\DBAL\Connection->executeCacheQuery('SELECT `order_id...', Array, Array, Object(Doctrine\DBAL\Cache\QueryCacheProfile)) 
#6 D:\XAMPP\htdocs\project1\models\TOrdersItem.php(1679): PHPMaker2024\GAProject\TOrders->getUserIDSubquery(Object(PHPMaker2024\GAProject\DbField), Object(PHPMaker2024\GAProject\DbField)) 
#7 D:\XAMPP\htdocs\project1\models\TOrdersItem.php(633): PHPMaker2024\GAProject\TOrdersItem->addDetailUserIDFilter('', 't_orders') 
#8 D:\XAMPP\htdocs\project1\models\TOrdersItemGrid.php(743): PHPMaker2024\GAProject\TOrdersItem->applyUserIDFilters('') 
#9 D:\XAMPP\htdocs\project1\views\TOrdersItemGrid.php(7): PHPMaker2024\GAProject\TOrdersItemGrid->run()
#10 D:\XAMPP\htdocs\project1\views\TOrdersAdd.php(237): include_once('D:\\XAMPP\\htdocs...')
#11 D:\XAMPP\htdocs\project1\vendor\slim\php-view\src\PhpRenderer.php(219): include('D:\\XAMPP\\htdocs...')

lissa
User
Posts: 73

Post by lissa »

The t_orders table is a local table in the database, the user table is a linked table.


sangnandar
User
Posts: 1031

Post by sangnandar »

user table is a special table.
If you want to to linked user table from another-db you might want to give it another name since user is also a reserved name.
I suggest to create view in another-db:

CREATE VIEW anothername AS
SELECT ...blah..blah..blah... from user;

lissa
User
Posts: 73

Post by lissa »

I tried to make a view and the result was successful.
Thank you.


lissa
User
Posts: 73

Post by lissa »

sorry I want to ask again,
when user A logs in based on id_user, user A can still see user B's data. it shouldn't be that user A can't see user B's data and vice versa.
this problem appeared after I created a view data in another-db


arbei
User
Posts: 9787

Post by arbei »

Make sure you have selected User ID field for the new view.


lissa
User
Posts: 73

Post by lissa »

I did use lookup table orders->id_user to linked table view (table user->id_user), but the lookup result of id_user in listpage does not show the lookup result "approved_by", only the id_user appears 12345 should be the name of the user being looked up. Is there a solution?


arbei
User
Posts: 9787

Post by arbei »

Normal users does not have access to the user table (which can only accessed by administrators), you may use your view (from the users table) as lookup table instead.


sangnandar
User
Posts: 1031

Post by sangnandar »

  1. If you enable User ID security and select id_user as the field, users can only see records relating to their id_user (or id_parent, if you enable Dynamic User Levels Security)
  2. If you give Lookup permission to a userlevelid, that userlevelid can see values BUT only records relating to their id_user as per defined security in (1)

Hence, you have to create separate table (a view table) for Lookup purpose.


lissa
User
Posts: 73

Post by lissa »

I want to ask again,
after I created a view on the login linked tables, I found another difficulty, when I added or changed the login data (linked tables) the password field was not encrypted,
note, my username password is directed to the login view table.
is there a way to encrypt the password field...


sangnandar
User
Posts: 1031

Post by sangnandar »

public function rowInserting($rsold, &$rsnew)
{
    $rsnew["password"] = EncryptPassword($rsnew['password']);
    return true;
}

public function rowUpdating($rsold, &$rsnew)
{
  if ($rsnew['password'] !== $rsold['password']) 
    $rsnew['password'] = EncryptPassword($rsnew['password']);
    return true;
}

lissa
User
Posts: 73

Post by lissa »

thank you very much for your help


Post Reply