douxia3505 2016-09-03 17:16
浏览 58

PDO和MySQL查询,与sqllite PostgreSQL,Oracle,MS SQL,ODBC等相同的查询?

For a long time I've been using MySQL and I'm using more MySQLi nowadays.

I'm thinking about switching to PDO or get more out of MySQLi. I don't know what will be better and how our future looks like, unfortunately :)

I've seen some examples online about PDO and have seen that CREATE, INSERT, DELETE, UPDATE query/functions are not the same.

example i need (depending on the query) to use :

$db->exec();
$db->execute();
$db->prepare();

Cause there are different ways to do the same it will make me personally confused and not easy to make a function or class of them.

My question here is if i can use the same query's with different databases or do i have to write my code depending on what database i use. I found this code online.. They are (almost but) not the same.

MySQL

$sql = "CREATE TABLE user (
id INT(11) NOT NULL AUTO_INCREMENT,
name VARCHAR(80) NOT NULL, 
email VARCHAR(50) NOT NULL, 
PRIMARY KEY (id))";

$mysql->exec($sql);

SQLLite

$sql = "CREATE TABLE books(
id int,
title varchar(255),
author varchar(255))";

$sqllite->exec($sql);

Do i miss something? Am i seeing this wrong? Can i write the same code for different databases? UPDATE, INSERT, DELETE, CREATE, DROP

Everybody writes positive about PDO... I am always seeing things different :) Maybe someone can share his opinion or awnser my question to start with, before to jump into something new. Thanks

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?
    • ¥15 c++头文件不能识别CDialog