⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Try to "CRUD" from a view



JPintor

JPintor
  • profile picture
  • Member

Posted 24 August 2012 - 11:31 AM

Hello again friends!!!

I have a new question, sorry for my english but I try to explain me:


I have 2 tables:

clients(id,name, distributor)

Distributors(id,name)



and 1 view:

dist_cli(id,name, number_of_clients)


I can work with the view????
Because the normal way use (the table way use) not work

someone idea??
thanks for you time!!

web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 24 August 2012 - 13:25 PM

You have to add the primary_key if you want to add a view. For example:


$crud->set_table('dist_cli');
$crud->set_primary_key('id');

saulimus

saulimus
  • profile picture
  • Member

Posted 24 August 2012 - 13:25 PM

Set the primary key for the view and it will work:
http://www.grocerycr...set_primary_key

set_primary_key('ID', 'dist_cli')


You might have a problem because both your tables have the primary key as 'ID' so it can't guess which one you're referring to.
You'd have to try and see what happens... but I guess it would be ok if you only use the view for reading data.

JPintor

JPintor
  • profile picture
  • Member

Posted 27 August 2012 - 08:11 AM

thank you very much for the two!!

I continue work with Grocery CRUD!! I'ts fantastic

RazorLegacy

RazorLegacy
  • profile picture
  • Member

Posted 16 October 2013 - 18:39 PM

CREATE TABLE IF NOT EXISTS `videos` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `active` enum('0','1') NOT NULL DEFAULT '1',
  `title` varchar(255) NOT NULL,
  `deck` mediumtext NOT NULL,
  `thumb` enum('0','1','2') NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `thumb` (`thumb`),
  KEY `active` (`active`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4337 ;

I apologize for bringing up a old post but I am having the same issue and my table does have the primary key all set up properly. No code changes were made but now I get "Fatal error: Cannot access empty property in app/libraries/Grocery_CRUD.php on line 1556"

 

Using PHP 5.5.4 and PDO, GroceryCRUD 1.4.1

 

Everything was working perfectly but then just stopped all of a sudden this morning.

 

var_dump($data->list) displays all table data to screen with no issues but the following is where the issue is. app/libraries/Grocery_CRUD.php

		foreach($data->list as $num_row => $row)
		{
			$data->list[$num_row]->edit_url = $data->edit_url.'/'.$row->{$data->primary_key};
			$data->list[$num_row]->delete_url = $data->delete_url.'/'.$row->{$data->primary_key};
			$data->list[$num_row]->read_url = $data->read_url.'/'.$row->{$data->primary_key};
		}

What is wrong here? Any suggestions are welcome.


majd94

majd94
  • profile picture
  • Member

Posted 09 April 2021 - 18:22 PM

You have to add the primary_key if you want to add a view. For example:
 

$crud->set_table('dist_cli');
$crud->set_primary_key('id');

 

I am using GC Enterprise und want to crud from a view. I did put the primary key and the table has correctly loaded. But when I click on read a row, it appears this error We can't process the response of the server. This is all we know about it:

Summary: 500 - Internal Server Error

Error: error

Response:


web-johnny

web-johnny
  • profile picture
  • Administrator
  • 1,166 posts

Posted 10 April 2021 - 07:48 AM

I am using GC Enterprise und want to crud from a view. I did put the primary key and the table has correctly loaded. But when I click on read a row, it appears this error We can't process the response of the server. This is all we know about it:

Summary: 500 - Internal Server Error

Error: error

Response:

 

Hello @majd94,

 

This is a very generic error and it can be anything really  :)

I have created a YouTube video for that to see how to debug it https://youtu.be/X0gnDD0qTS8 Although this is for Grocery CRUD community edition you can follow the same steps for Grocery CRUD Enterprise as well.

 

Let me know if that helped.

 

Regards

Johnny


majd94

majd94
  • profile picture
  • Member

Posted 10 April 2021 - 09:57 AM

Hello John, thanks for your reply. I really have checked every thing, seemed to be a connection database error only when click on read, edit (by using view as a table). Do you have a solution?
This is the response that I get when calling a specific row:

An uncaught Exception was encountered

Type: Zend\Db\Adapter\Exception\InvalidQueryException

Message: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '= '1'' at line 1

Filename: C:\xampp\htdocs\plesung\application\libraries\GroceryCrudEnterprise\zendframework\zend-db\src\Adapter\Driver\Mysqli\Connection.php

Line Number: 240

 

 

 


majd94

majd94
  • profile picture
  • Member

Posted 13 April 2021 - 12:14 PM

Any idea?