键入:PDOException
代码:42S22
消息:SQLSTATE [42S22]:未找到列:1054冠军'id'不在乎其中的子句 文件:C:\ wamp \ www \ viversoft \ vendor \ j4mie \ idiorm \ idiorm.php 行:413
<form role="form" class="form-horizontal" method="POST">
{% if is_admin %}
<a href="{{urlFor('altausers')}}" class="btn btn-primary pull-right">Crear usuario</a>
{% endif %}
<h2>Listado de usuarios</h2>
{% if users %}
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>Nombre de usuario</th>
<th>Email</th>
<th>Administrador</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td class="text-center">{{ user.idusuario }}</td>
<td class="text-center">{{ user.username }}</td>
<td class="text-center">{{ user.email }}</td>
<td class="text-center">{%if user.admin == 1 %} SI {%else%} NO {% endif %}</td>
{% if is_admin %}
<td>
<a href="" class="btn btn-primary" role="button">Modificar</a>
<button type='submit' name="eliminar" id="eliminar" value="{{user['idusuario']}}" class="btn btn-danger" onclick="deleteconfirm(this.value);">Eliminar</button>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info">No hay usuarios para mostrar</div>
{% endif %}
</form>
$app->post('/users', function() use($app){if(isset($_POST['eliminar'])){
$user = ORM::for_table('usuario')->find_one($_POST['eliminar']);
if($user)
{
$user->delete();
$app->redirect($app->urlFor('userList'));
}
}})->name("userDelete");
CREATE TABLE IF NOT EXISTS `usuario` (
`idusuario` int UNSIGNED NOT NULL AUTO_INCREMENT,
`username` varchar(45) NOT NULL,
`contrasenia` varchar(255) NOT NULL,
`email` varchar(45) NOT NULL,
`admin` tinyint(1) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`idusuario`))
ENGINE = InnoDB;
答案 0 :(得分:2)
我认为你有问题,我不确定
// $ user = ORM :: for_table(&#39; usuario&#39;) - &gt; find_one($ _ POST [&#39; eliminar&#39;]);
按如下所示更改上述行,然后尝试
$user = ORM::for_table('usuario')->find_one(array('idusuario' => $_POST['eliminar']));