简体   繁体   English

如何使用 Laravel 进行 SQL 查询 (ORACLE)?

[英]How to do SQL queries (ORACLE) using Laravel?

I wanted to know how to use Laravel framework in my projects, I'd like to use Oracle as my DB(cuz' is the db that I always use).我想知道如何在我的项目中使用Laravel框架,我想使用Oracle作为我的数据库(因为我一直使用的数据库)。

The First things that I find are "Entity Relational Model":我发现的第一件事是“实体关系模型”:

  • One-to-One Relationships一对一关系
  • One-to-Many Relationships一对多关系
  • May to One Relationships五一关系
  • Many-to-Many Relationships多对多关系

But my doubt is, How be possible to do SQL queries with Oracle syntax on Laravel ?但我的疑问是,如何在Laravel上使用Oracle语法进行SQL查询?

For Example, this Query (I Found on internet ):例如,这个查询(我在互联网上找到的):

WITH dept_count AS (
  SELECT deptno, COUNT(*) AS dept_count
  FROM   emp
  GROUP BY deptno)
SELECT e.ename AS employee_name,
       dc.dept_count AS emp_dept_count
FROM   emp e
       JOIN dept_count dc ON e.deptno = dc.deptno;

Sorry for my English, I speak Spanish :)对不起我的英语,我说西班牙语:)

You can execute raw statements using the DB::raw method of the database query builder.您可以使用数据库查询构建器的DB::raw方法执行原始语句。 Think of it as pass-through statements.将其视为传递语句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM