CodeIgniter Forums
Function delete is now working in DataMapper OverZealous Edition 1.7.0 - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Function delete is now working in DataMapper OverZealous Edition 1.7.0 (/showthread.php?tid=28616)



Function delete is now working in DataMapper OverZealous Edition 1.7.0 - El Forum - 03-16-2010

[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???


Function delete is now working in DataMapper OverZealous Edition 1.7.0 - El Forum - 05-25-2013

[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


Function delete is now working in DataMapper OverZealous Edition 1.7.0 - El Forum - 05-26-2013

[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.