Yii Migration Runs Successfully, But Results Are Partial - php

I wrote a particularly long migration for my website, and unfortunately was caught altering it quite a bit (I know I'm supposed to write additional migrations, instead of altering preexisting ones, but this wasn't possible in this case).
This is a complex migration, so I wrote it into the safeUp() function, as it should be wrapped in a transaction. When I run the migration, everything seems to work perfectly. It shows me each SQL command as it runs, and then at the end, says it ran successfully. The migration appears correctly in the history. However, when I visit the database, I realize that the migration is only partially done. Which should be impossible because it was written in safeUp().
It should be noted that I was running many migrations at once, and that each one runs successfully. The only time I got it to work, I ran every other migration up until the one in question (using ./yiic migrate to timestamp), and then copy pasted the sql into phpmyadmin, and ran it manually. Boom, perfectly done.
Anyone run into this problem?
-- Edit: I believe the issue here was that Yii parses SQL comments in an interesting way when it runs inside the $this->execute('sql'), so that the SQL it was generating was not identical to the raw SQL.
-- Edit2: This is ages ago now, but I'm now learning about this bug https://github.com/yiisoft/yii2/issues/9894. I think it may apply to Yii1 as well, if anyone out there is reading this.

Related

Update PHP code on a server running the Laravel framework

I am the sole person in charge of a website that keeps track of records that other employees submit and compiles them into nice spreadsheets so that non-technical users can easily read them.
The other guy who used to work here quit unexpectedly, and I have to make a small, one-line change to the PHP code that he wrote, the problem is, when I edit the code, it does not seem to change anything. For example, I can completely delete the code that displays an error message, but that error message will still show up. There are other parts of the project that I CAN modify, like XML files and python programs, but the PHP does not seem to care if it is modified.
I vaguely remember a command like 'php artisan serve' but that doesn't seem to help either
After googling the problem, I came across several other commands like 'npm run production' and 'php artisan optimise' but those didn't work either.
Thanks for your help
Are you changing the code directly on the server? Or are you trying it local first? Is the change on a view-file?
Try php artisan cache:clear. It should clear all the caches and probably show your changes.

where to find Phprunner query logs?

i have a project generated by Phprunner. some pages respond very slow. then i thought i must inspect generated and executed queries somehow. i'v tried searching trough code and i found lot's of execute functions. i don't know which one is the right execute point.
i'm using Phprunner 9.0 ,Php 5.6 and MySQL.
where can i find the log file or the right spot for putting logger?

Can I debug my Laravel migration by writing to standard out? How?

I am running a set of migrations that denormalize one of my tables. I am running some code in one of the migrations that sets the ids in a new table based on the content of the current table.
For some reason, the id is not getting written correctly. To debug this, I would like to echo some of the variables out to the command line when I run the migration (in development). However, I have so far been unable to get those commands to work.
Yes, you can use all the usual ways (echo, var_dump, print_r). They will output normally to the command line in migrations.
If you suspect (as I did) that something about Laravel's migration system is silencing them, you are barking up the wrong tree.

Why does my MySQL database tables only exist on my Workbench?

I am developing my first php-MySQL system, but have a minimum of database experience. I have successfully created a schema with aproximately 10 tables, and the testings have so far worked fine.
My problems started when i created a dump of the database, as copy for my laptop, so I could continue to test new web pages and new queries even when I am not at home, and still use a localhosted database.
I have successfully imported the dump, and created the schema in my workbench, and it is visible from the command-line prompt "show databases".
However, both my web application, and the command-line prompts are unable to locate the underlying tables. THe problem is at least not directly in my php-code, as it works perfectly on another computer, with another, but assumably identical localhosted database. I have researched the matter online for what feels like a decade, but without any relevant results.
Command-line prompts are able to find tables from every other schema, like the sakila examples. I have tried to compare the two's settings, but they all seem to be identical, for instance they are both InnoDB.
I realise that I am not giving enough information for a direct solution here, but I would greatly appreciate if anyone could hguide me to finding the right questions to ask, so I can solve this matter, and get on with my php-learning.
(SOLVED)
I discovered that the list of open tables had references to an additional Schema. I thereafter realised that I had installed the XAMPP bundle server before I installed MySQL Workbench. In other words, i already had an existing database, with all of the regular examples included in another instance, which were running on port 3306. It also happpened to have an identical, but empty scheme, of the name that I tried to access.
My newly added SQL installation was ported to 3307, and so I am now able to access it. THis issue was just one of several issues I have been able to work around, but they have all been caused by the same mistake. Thanks everyone for trying to help.

SQLite, PDO, and PHP: New inserts not being saved

I have a few PHP (version 5.1.6) scripts and an sqlite3 database. For a while, everything was working fine, including inserts, updates, selects, and deletes.
Now:
Select statements still work fine
Inserts, deletes, and updates all fail without an error that I can see. A -journal file is created in the same directory as the database, but it later disappears. The sqlite file remains unmodified.
I can't really figure out what, if anything, has changed. Permissions are the same. I've been able to open and save the database in another program, and replaced it with that version, but I still have the same problem. The scripts originally were all in autocommit mode; using explicit commits does not fix the problem either.
If I replace the database file with an older backup, everything works just fine.
I'd appreciate any ideas for troubleshooting. Thank you!
Take a closer look at the permissions. Make sure PHP/Apache has read/write capability and owns the folder and the SQLite database file.

Categories