Jump to content


Try to "CRUD" from a view

views tables

  • Please log in to reply
4 replies to this topic

#1 JPintor

JPintor

    Newbie

  • Members
  • Pip
  • 5 posts
  • LocationAlcazar de San Juan, España

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!!
Javier Pintor

#2 web-johnny

web-johnny

    grocery CRUD Author

  • Administrators
  • 1,101 posts
  • LocationLondon

Posted 24 August 2012 - 01: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');

Posted Image

#3 saulimus

saulimus

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 24 August 2012 - 01: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.

#4 JPintor

JPintor

    Newbie

  • Members
  • Pip
  • 5 posts
  • LocationAlcazar de San Juan, España

Posted 27 August 2012 - 08:11 AM

thank you very much for the two!!

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

#5 RazorLegacy

RazorLegacy

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 16 October 2013 - 06: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.







Also tagged with one or more of these keywords: views, tables

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users