Trying to execute a SQL Server stored procedure on a server using codeigniter but it seems that the query doesn't get any output and no error prompts either, for now I've removed the parameters thinking that it will smooth things up but it didn't.
Is it possible to access this stored procedure and if it is, can I also run it with parameters like two date parameters?
PS: All the connections are good I've tried to retrieve records from another table from this SQL Server and I got it..
Related
I wanted to know if this was possible. Hope I'm asking this question the right way.
Can you write SELECT query locally without using the server? I can connect using certificate key and MySQL workbench but can't connect to the database on the server using the same credentials.
I'm using Php but don't know any other way to SELECT table and retrieve data for my React application without writing code on the server in a Php file to access the data?
I have old apps which using VB6 and SQL Server 2000. This apps is build for offline purpose. Now, we want to get daily report via Online through website.
[local]
VB6
SQL Server 2000
[VPS]
PHP7
Mysql
What i done is, create install XAMPP in local server then use cronjob every 10min to execute sync.php which will syncronize db from SQL Server to Mysql.
My script flow:
foreach (SQL_SERVER_RESULT)
{
if(!checkExistOrNotInMysql()) insertDataToMysql()
}
I just check if data is already stored in VPS or not. If not, data will be inserted.
The Problem is : i cant check if data in SQL server is UPDATED. If i check updated data, it will force me to check WHOLE data in Mysql in every Cronjob (bad thing).
So, my question is, what is the best way to do this?
thanks for advance.
I've opened a bug report against MySQL http://bugs.mysql.com/bug.php?id=70793&thanks=4. There is a code example here that demonstrates this on this bug. There is also a workaround that I found that is included in the bug report. This workaround works for PHP and console
I'm running into a bizarre issue with a Stored Procedure and PHP PDO.
I am not allowed to post the body of the stored procedure, but I can provide the following information.
It works correctly on a read only replica when accessed from console with the same user that PHP PDO shares -- Edit: My initial report here is partially incorrect, the stored procedure will work if the temp table exists and will fail if the temp table doesn't exist in both console and pdo environments. See the linked bug report to MySQL for details.
I have verified that I am using the same user in both places.
The only write activity it performs is inside a temp table
It does utilize a cursor
The master and replica are both running MySQL 5.5.27
The MySQL servers are managed on AWS RDS; I have a single parameter group with a standard configuration.
My issue is that I cannot call this stored procedure from PHP PDO, I get this error
SQLSTATE[HY000]: General error: 1290 The MySQL server is running with the --read-only option so it cannot execute this statement
This makes absolutely no sense because I can call this on the read only replica as long as I'm not doing it from PHP.
Can anyone shed any light on what might be going on here?
Edit More bizarre information
I can get a console session to fail, but I can also make it succeed. It depends on if the temporary table that the stored proc uses has already been created. So let me explain my working and failing use cases
Fail
Login to the server on console
Try to call the stored proc
Fail The MySQL server is running with the --read-only option so it cannot execute this statement
Pass
Login to the server on console
Create the temp table
Try to call the stored proc
Success
Even stranger is that I most definitely drop that temp table inside the the stored proc and recreate it if it exists.
I'm reasonably certain at this point we are looking at a MySQL bug
Did you try adding the TEMPORARY keyword to the DROP TABLE command?
The TEMPORARY keyword has the following effects:
The statement drops only TEMPORARY tables.
The statement does not end an ongoing transaction.
No access rights are checked. (A TEMPORARY
table is visible only to the session that created it, so no check is
necessary.)
--read-only is only for non-root or non-replica-user. Thus, ROOT from console can still do anything but not the PHP user.
I'm in the process of moving a PHP application from an Ubuntu server to an AWS openSUSE instance.
The application does not work on the openSUSE box. The API fails for any call that has $mysqli->insert_id. Calls using $mysqli do work.
From reading around I have noted that this usually fails because of auto_increment not being implemented on the Database column. I migrated the MySQL database across from the Ubuntu hosted app. The table schema seems to be the same.
I have also looked at the server configuration files php.ini etc. and the MYSQLi extensions seem to be configured correctly.
It is for this reason I think it is a PHP related problem. Any help would be greatly appreciated.
EDIT : To provide more information as requested.
The general structure of each API call that fails is.
The iOS sends a POST to the API
The API (built in PHP) inserts the information into a Table which has a Primary Key that auto-increments.
The API then uses $case_id = $mysqli->insert_id;, obtain the value of this primary key.
This value is returned to the iOS app.
Important - $case_id is being returned as 0.
To troubleshoot an issue like this I would start by isolating where the problem is occurring. Is the schema wrong? If you log into the MySQL server using the MySQL shell and you attempt to manually insert a record, with a NULL for the auto-incremented (primary key?) column does the new record appear properly? If you query using the same underlying SQL statement that's being generated and passed to the server from your PHP/mysqli component does it return the proper row(s)?
If it works using the MySQL shell on the DB server then what if you try the same from the API server? Is it a permissions/ACL or networking issue? If the it works from the MySQL shell on both the DB server and the API (web?) server then does it work from your PHP code? Perhaps you can refactor your PHP to allow you to run tests/diagnostics from the command line (rather than attempting to initiate a transaction through the additional web/UI layers). (This is generally a good idea when writing your web applications anyway). Perhaps you can separate the web/form/ReST handling (view) from the code which passes data back into the DB (the model). Thus you isolate the controller code from the rest and can re-use it for diagnostics and for monitoring.
If you can't get it working even from the DB server's only MySQL shell prompt then you probably have a problem in the schema. Go back to the working DB server and perform a schema dump as described here: http://forums.mysql.com/read.php?35,128003,128105
Then restore that. It should then be a completely empty database with your working schema intact. If that doesn't work then it suggests you have some issues even lower (MySQL version and modules perhaps, missing some storage backends?)
I am doing an mysql php application and I need to create a procedure to make my foreign keys work fine and also to create a calendar for report purposes. However, I have been trying to create the procedures and it does not works in putty.exe which is the only software available to do my application. I researched and I did not find anything related to this. Can anyone advise if I will need extra files for putty or the way to do it?
You need to use the mysql client to run commands against mysql. In the putty command line just run:
mysql
You will most likely need to add parameters to the command, like the user and the password needed to connect. Check the MySQL manual for details.
To run the script file that contains your procedure, first you have to upload the file to the server and then run it with
mysql < script.sql