Here is a snippet of my code:
$qry = '
INSERT INTO non-existant-table (id, score)
SELECT id, 40
FROM another-non-existant-table
WHERE description LIKE "%:search_string%"
AND available = "yes"
ON DUPLICATE KEY UPDATE score = score + 40
';
$sth = $this->pdo->prepare($qry);
$sth->execute($data);
print_r($this->pd...
I needed to change a query into a JOIN of two tables.
$q = "SELECT * FROM table1 AS a JOIN table2 AS b USING(id) WHERE a.id= $id";
$stmt = db::getInstance()->prepare($sql);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
All off the sudden I cannot refer to each row value with $rows['value']
,BUT I need to use $rows[0]['value'].
How can I ...
In order to do a LIKE search with PDO, I need to add the % to the parameter before passing it.
This works:
$qry = '
SELECT product_id
FROM cart_product
WHERE product_manufacturer_num LIKE :search_string
';
$sth = $this->pdo->prepare($qry);
$sth->execute( array("search_string"=>'%'.$search_string.'%') );
To me this feels ...
This error appears when executing the code below:
Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[42000]: Syntax error or access violation: 1065 Query was empty'
in /home/content/63/6563663/html/inventory/pg.php:20
Stack trace:
#0 /home/content/63/6563663/html/inventory/pg.php(20): PDOStatement->execute()
...
This PDO request is not welcomed by my server for some reason. It makes the server throw a 500 Internal Server Error. All of my other PHP files are working fine and I haven't changed any server settings. Strangely though, It seems that when I comment out the line that binds the variable $u, it does not give a 500 error. I am perplexed.
...
I have researched online but most examples or instructions don't seem to apply to what I am trying to accomplish.
In short my code should accomplish the following:
A stored procedure is called from my php script which returns a dataset I want to loop through and produce rows in a table (for online display purposes). One of the fields ...
I use remote server to store values into MySQL database.
I don't use any SELECT queries, only INSERT, DELETE and UPDATE.
When I execute 70,000 queries I have trouble with speed.
I was trying mysql_unbuffered_query and I saw little performance profit but it's still too slow.
I remember that some functions in PHP allow me to execute se...
I understand the right way to protect a db from SQL injection is by using prepared statements. I would like to understand how prepared statements protect my db.
For starters, are prepared statements the same thing as "parameterised queries"?
As an example, I'm pasting below my code for the insertion of a new user in a user table. I...
Having problems with and update query i keep getting
Warning: Crud::update() [crud.update]: Property access is not allowed yet in crud.php on line 60
This is my code
$stmt = $this->mysql->prepare('UPDATE links SET title = ?, url = ?, comment = ? WHERE id = ?');
$stmt->bind_param('sssi',$title,$url,$comment,$id);
$stmt->execute();
...
PDO for SQLite3 is done already. Have you got any way to use PDO with CodeIgniter for other Databases? How did Codeigniter skip PDO for other databese-servers, I dont get it. Expect you may know better and can pick us up.
EDITED:
Any tricks/way to build our own PDO class is highly appreciable.
...