$db from Load - How to delete from db table?

Permalink
Ive been able to select and update using $db but cannot Delete a row! Amazing ... and can't find any documentation online that will provide a nice how and/or samples on how to do CRUD, etc. Is there any documentation as reference to see how to use the $db object?

Anyway

$sql = "delete from aa_wall_block";
$v = $db->Execute($sql);

OR

$sql = "delete from aa_wall_block";
$v = $db->query($sql);

does NOT work! What am I missing for this simple query?

thanks

 
bbeng89 replied on at Permalink Reply
bbeng89
Are you loading in the db properly first like this:
$db = Loader::db();


If so, you should just be able to do:
$db = Loader::db();
$db->Execute("delete from aa_wall_block");


Also, on some platforms I believe your query is case sensitive so you will want to double check that the case of your table name is correct.
tsdonohue5 replied on at Permalink Reply
Thanks for answer but that is the code I have and will not work. when I run the sql in mysql it deletes. So it seems I have correct sytax but does not work even though selects, update, etc. work.

Well, it's just bizarre that this doesn't work but other db actions do.

I've have to use my own db class to bypass this.

Are there any web pages with lots of sample code for using the $db object?

thanks
bbeng89 replied on at Permalink Reply
bbeng89
Hm, that is strange. The concrete5 documentation on database access is here:

http://www.concrete5.org/documentation/introduction/database-access...

It uses ADODB, so I have also used the following site as a reference:

http://phplens.com/lens/adodb/docs-adodb.htm...
tsdonohue5 replied on at Permalink Reply
thanks for the help. I'll figure this out one way or another.
JohntheFish replied on at Permalink Reply
JohntheFish
Could it be server or mysql access permissions, outside of c5?
ConcreteOwl replied on at Permalink Reply
ConcreteOwl
instead of
("delete from aa_wall_block")

try
('delete from aa_wall_block')
tsdonohue5 replied on at Permalink Reply
Hey Guys, thanks so much for the responses.

THE PROBLEM WAS WITH THE OBJECT TYPING ON THE KEYBOARD!!!!

It was problem with my code elsewhere in the page ... it happens!

Thanks!