function testDeleteWhere() { $row = array('title' => 'delete', 'body' => 'delete'); $count = 5; for ($i = 0; $i < $count; $i++) { $this->table->insert($row); } $this->table->delete('title = ? AND body = ?', 'delete', 'delete'); $affected_rows = $this->table->getConn()->affectedRows(); $this->assertEquals($count, $affected_rows); $this->table->delete(null); $affected_rows = $this->table->getConn()->affectedRows(); $this->assertTrue($affected_rows > 1); }
/** * 开启一个查询,并根据提供的参数设置查询对象 * * @param array $args * * @return QDB_Select */ function findByArgs(array $args = array()) { $select = new QDB_Select($this->table->getConn()); $select->asColl()->from($this->table)->asObject($this->class_name); $c = count($args); if ($c > 0) { if ($c == 1 && is_int($args[0]) && $this->idname_count == 1) { $select->where(array(reset($this->idname) => $args[0])); } else { call_user_func_array(array($select, 'where'), $args); } } if ($this->inherit_base_class && $this->inherit_type_field) { // 如果是来自某个继承类的查询,则限定只能查询该类型的对象 $select->where(array($this->inherit_type_field => $this->class_name)); } return $select; }
/** * 开启一个查询,并根据提供的参数设置查询对象 * * @param array $args * * @return QDB_Select */ function findByArgs(array $args) { $select = new QDB_Select($this->table->getConn()); $select->asObject($this->class_name)->from($this->table); $c = count($args); if ($c > 0) { if ($c == 1 && intval($args[0]) == $args[0] && is_numeric($args[0]) && $this->idname_count == 1) { $select->where(array(reset($this->idname) => $args[0])); } else { call_user_func_array(array($select, 'where'), $args); } } return $select; }
/** * 开启一个查询,并根据提供的参数设置查询对象 * * @param array $args * * @return QDB_Select */ function findByArgs(array $args) { $select = new QDB_Select($this->table->getConn()); $select->asObject($this->class_name)->from($this->table); if (count($args)) { call_user_func_array(array($select, 'where'), $args); } return $select; }