pdo

How to write multi query in PHP using database extension PDO

戏子无情 提交于 2021-01-28 20:07:12
问题 I would like to write this MYSQL query SET @val := 0; SELECT `my_table`.* FROM `my_table` HAVING (@val := @val + 1) > 0; inside PHP code that using database extention PDO ! I've seen that mysqli have mysqli_multi_query() but i do not know does PDO support multi queries by some how?! I've try this <?PHP // i'm connected to db $sql = "SET @val := 0;"; $sql .= "SELECT `my_table`.* FROM `my_table` HAVING (@val := @val + 1) > 0;"; ?> <table> <tr> <th>id</th> <th>name</th> </tr> <?PHP foreach($db-

Running SQL scripts to PostgreSQL using PHP/PDO

↘锁芯ラ 提交于 2021-01-28 13:36:50
问题 I need to run some SQL scripts to my database, to update the schema and data (some kind of migration). Because there is some logic to check before running each script, I'm writting a small PHP tool to execute the scripts, but I have a simple problem: Can I load and execute a "simple" SQL script (including table manipulation, triggers & stored procedures updates) directly, or should I add markers to the script (to mark where each sentence ends), and run the script sentence by sentence? For the

Running SQL scripts to PostgreSQL using PHP/PDO

我只是一个虾纸丫 提交于 2021-01-28 13:32:55
问题 I need to run some SQL scripts to my database, to update the schema and data (some kind of migration). Because there is some logic to check before running each script, I'm writting a small PHP tool to execute the scripts, but I have a simple problem: Can I load and execute a "simple" SQL script (including table manipulation, triggers & stored procedures updates) directly, or should I add markers to the script (to mark where each sentence ends), and run the script sentence by sentence? For the

Running SQL scripts to PostgreSQL using PHP/PDO

淺唱寂寞╮ 提交于 2021-01-28 13:32:41
问题 I need to run some SQL scripts to my database, to update the schema and data (some kind of migration). Because there is some logic to check before running each script, I'm writting a small PHP tool to execute the scripts, but I have a simple problem: Can I load and execute a "simple" SQL script (including table manipulation, triggers & stored procedures updates) directly, or should I add markers to the script (to mark where each sentence ends), and run the script sentence by sentence? For the

Php PDO sql statement with single quotes

ε祈祈猫儿з 提交于 2021-01-28 10:04:59
问题 I have a mysql php pdo statement that has single quotes to call the Mysql Geolocation "POINT" function as such. $sql = "INSERT INTO userTrip (userId, fromLat, fromLon, fromLoc, fromPOI, toLat, toLon, toLoc, toPOI, tripFinished, isMatched, departureTime, createdAt) values (:user,:fromLat,:fromLon, GeomFromText('POINT(:fromLat1 :fromLon1)'),:fromPOI,:toLat, :toLon, GeomFromText('POINT(:toLat1 :toLon1)'),:toPOI,0,0,:departureTime,:date)"; $stmt = $db->prepare($sql); $stmt->bindParam(':user',

Notice: Trying to access array offset on value of type bool in C:\xampp\htdocs\twitter\core\classes\follow.php on line 25

淺唱寂寞╮ 提交于 2021-01-28 08:34:21
问题 Everything seems to be working good but i am getting an error: I checked for typos in my follow.php and profile.php and even retyped the major part of the code but was not able to figure out the problem. This is my line 25 of follow.php if($data['reciever'] == $profileID) Here is my follow.php <?php class Follow extends User { function __construct($pdo) { $this->pdo = $pdo; } public function checkFollow($followerID, $user_id) { $stmt = $this->pdo->prepare("SELECT * FROM `follow` WHERE `sender

Results of a PDO query not displaying

ⅰ亾dé卋堺 提交于 2021-01-28 06:28:26
问题 I'm trying to make a PDO query to display data. This is what i have done so far : in my models/pdo, i created a class with this: <?php class VengeanceUsers { public static function getNumbersOfregistered() { $connexion = new PDO("mysql:host=localhost ;dbname=databasetest", 'root', 'passe'); // connexion à la BDD $var_dump($connexion); exit(); $resultats=$connexion->query("SELECT COUNT (*) FROM ope_tartine_nl "); // on va chercher tous les membres de la table qu'on trie par ordre croissant

Query does not return a result

陌路散爱 提交于 2021-01-28 06:22:18
问题 I converted a web-based application from MySQLi to PDO, because I want to use Microsoft SQL-Server as database too. PDO works like a charm with MySQL database. Now I tried it for the first time with MS-SQL and it does not. Almost every query has to be updated. It is very frustrating. The simple code below drives me nuts: $ComputerGUID = "5BEC3779-B002-46BA-97C4-19158C13001F"; $SqlSelectQuery = "SELECT computermapping.PrinterGUID, case when computerdefaultprinter.PrinterGUID IS NOT NULL then 1

Call SQL Stored Procedure from PHP PDO

孤者浪人 提交于 2021-01-28 05:18:37
问题 I need to call a stored procedure to insert the data to sql and it return a value with output parameter like CREATE PROCEDURE InsertInfo @userid VARCHAR(100), @login_time DATETIME, @IsSuccuess BIT, @loginid INT OUTPUT AS BEGIN INSERT INTO Audit_LoginLogoutAttempt(UserID,Login_Time, IsSuccuess, DateCreated) VALUES (@userid,@login_time,@IsSuccuess, GETDATE()) SET @loginid = @@IDENTITY END GO How to send input and output parameters using PHP $stmt = $conn->prepare("{CALL InsertInfo(?, ?, ?, ?)}"

Bind OCI sysdate() to PDO parameter?

社会主义新天地 提交于 2021-01-28 04:42:42
问题 I want to bind sysdate function in my PDO prepared query : $db = new PDO('oci:dbname=database;charset=UTF8', 'user', 'pass'); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $query = $db->prepare('SELECT :func FROM DUAL'); $query->execute(array(':func' => 'SYSDATE()')); var_dump($query->fetch()); The result return this : array (size=2) ':FUNC' => string 'SYSDATE()' (length=9) 0 => string 'SYSDATE()' (length=9) I want to get the system date of my oracle database. Is it possible ?