我在尝试php artisan db:seed时收到错误
照亮\数据库\查询异常
SQLSTATE[42S22]:未找到列:1054“字段列表”中的未知列“简短描述”(SQL:插入到类别中
(name
,slug
,short\u description
,description
,常规价格
,SKU
,库存状态
,数量
,图像
,类别id
,更新的
,创建的
)值(无论是口头上还是口头上,我都会拒绝所有人和个人的意见,包括暂时性的非口头上的意见。如果是口头上或口头上的意见,那么就不应该是口头上的意见。如果是口头上的意见因此,所有人都必须具有非共和国的特殊性。这是一种特殊性。这种特殊性是指权利的特殊性。除权利和义务的巨大性外,其他权利的特殊性。临时性的准权利属于实践性的权利。这是一种类似的权利莫迪·诺斯特鲁姆,330,迪吉378,因斯托克,158,迪吉奥(2021-04-16 21:12:052021-04-16 21:12:05))
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Category extends Model
{
use HasFactory;
protected $table = "categories";
}
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
class Product extends Model
{
use HasFactory;
protected $table = "products";
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateProductsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('products', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('slug')->unique();
$table->string('short_description')->nullable();
$table->text('description');
$table->decimal('reqular_price');
$table->decimal('sales_price')->nullable();
$table->string('SKU');
$table->enum('stock_status',['instock','outofstock']);
$table->boolean('featured')->default(false);
$table->unsignedInteger('quantity')->default(10);
$table->string('image')->nullable();
$table->text('images')->nullable();
$table->bigInteger('category_id')->unsigned()->nullabe();
$table->timestamps();
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('products');
}
}
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreateCategoriesTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('categories', function (Blueprint $table) {
$table->id();
$table->string('name')->unique();
$table->string('slug')->unique();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('categories');
}
}
namespace Database\Factories;
use App\Models\Category;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class ProductFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Category::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$product_name = $this->faker->unique()->words($nb=4,$asText=true);
$slug = Str::slug($product_name);
return [
'name' => $product_name,
'slug' => $slug,
'short_description' => $this->faker->text(200),
'description' => $this->faker->text(500),
'regular_price' => $this->faker->numberBetween(10, 500),
'SKU' => 'DIGI'.$this->faker->unique()->numberBetween(100, 500),
'stock_status' => 'instock',
'quantity' => $this->faker->numberBetween(100, 200),
'image' => 'digital_'.$this->faker->unique()->numberBetween(1, 22),
'category_id' => $this->faker->numberBetween(1, 5),
];
}
}
namespace Database\Factories;
use App\Models\Category;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
class CategoryFactory extends Factory
{
/**
* The name of the factory's corresponding model.
*
* @var string
*/
protected $model = Category::class;
/**
* Define the model's default state.
*
* @return array
*/
public function definition()
{
$category_name = $this->faker->unique()->words($nb = 2, $asText = true);
$slug = Str::slug($category_name);
return [
'name'=>$category_name,
'slug'=>$slug,
];
}
}
在productFactory上,更改:
protected $model = Category::class;
到
protected $model = Product::class;
我正在尝试使用PDO向MySQL插入一条记录,下面的代码中可以看到我的sql语句。 当执行此代码时,我会遇到以下错误消息; SQLState[42S22]:找不到列:1054“Field List”中的未知列“John” 这无疑是解决这个问题的一个简单方法,但我似乎看不出来,有人能给我指明正确的方向吗?
问题内容: 我正在使用Laravel框架。 我有2个表(用户和成员)。当我想登录时,收到错误消息: SQLSTATE [42S22]:找不到列:1054’where子句’中的未知列’user_email’(SQL:select * from where =?limit 1)(绑定:数组(0 =>'test@hotmail.com‘,)) 表用户 表成员 迁移用户 移民会员 模型使用者 模范会员 成
我使用的框架Laravel。 我有两个表(用户和成员)。当我想登录时,我会收到错误消息: SQLSTATE[42S22]:找不到列: 1054未知的列'user_email'in'where子句'(SQL:选择*fromwhere=?限制1)(绑定:数组(0= 表用户 表成员 迁移用户 移民成员 模型用户 模范会员 成员模型使用:使用照明\Auth\UserInterface; 控制器 auth.
我是编程界的新手,我自己在学习laravel,我发现了这个错误:SQLSTATE[42S22]:Column not found:1054未知列'clientes.clientes\u id'在'where子句中(SQL:select*fromwhere=1和不为空)(视图:/shared/httpd/laravel_8_crud/resources/views/pedidos/index.bla
SQLSTATE[42S22]:找不到列: 1054未知列'products.wishlist_id'in'where子句'(SQL:选择*fromwhere.=1 and>.不是null和.是null)
我得到以下错误SQLSTATE[42S22]:未找到列:1054“where子句”中的未知列“id”(SQL:选择count(*)作为来自