Welcome Guest, Not a member yet? Register   Sign In
Function delete is now working in DataMapper OverZealous Edition 1.7.0
#1

[eluser]Diego CODU[/eluser]
This is my code:

Code:
function apagar($id)
{
$d = new Destaque();
$d->where('destaque_id', $id)->get();

$d->delete();
}

But it´s not working...
I'v tried to see the last query using:

$d->chech_last_query();

But it's show only this:

Code:
SELECT *
FROM (`destaques`)
WHERE `destaques`.`destaque_id` = '21'

What am I doing wrong???
#2

[eluser]Unknown[/eluser]
I'm new in datamapper and, I Have the same problem Diego Codu.

Code:
$d = new Functionary;
$d->where('people_id',$queryResult->people_id)->get();
$d->delete();
$d->check_last_query();

The answer is:

Code:
SELECT *
FROM (`functionaries`)
WHERE `functionaries`.`people_id` =  '64'

Anyone have a solution?

thanks, sorry about my engliSH :d
#3

[eluser]WanWizard[/eluser]
I think in both cases you don't have a table with 'id' as primary key.

Datamapper requires ALL tables to have a primary key column called 'id', which ideally is auto_increment.

The delete() method uses that ($d->id in this case) to check if a primary key is present, because if not, there is nothing to delete.




Theme © iAndrew 2016 - Forum software by © MyBB