PHP 或者 ThinkPHP 中有什么方法可以在代码中删除表记录

WBOY
Release: 2016-06-23 14:14:06
Original
776 people have browsed it

 最近在做一个demo,需要适时更新数据库,之前的数据要全部删掉,同时又4张表要删除,我抽出了一个方法,把表名传进来,但是php/ThinkPHP在删除数据的时候,如果没有加where条件不会删除,谁有好的想法啊,在线等待中……


回复讨论(解决方案)

$model = M('表名');
$rows = $model->where('1=1')->delete();
echo $model->getLastSql().'
一共删除了你懂的:'.$rows;

十分感谢,分不多……

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template